Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jimmy Byrd
    @TheAngryByrd
    luckily it was really easy to add
    we have some source-map warnings but at least it's working ;)
    Maxime Mangel
    @MangelMaxime
    Ok thank you for the explanation :)
    Steffen Forkmann
    @forki
    hey @MangelMaxime
    fulma docs don't say how to react to changes
    should I add OnClick to Dropdown.Item.a?
    Steffen Forkmann
    @forki
    image.png
    can't find it
    Maxime Mangel
    @MangelMaxime
    Hello @forki , yes you should attach an OnClick listener to each element of your form.
    Steffen Forkmann
    @forki
    but how?
    it says it's not a thing
    Maxime Mangel
    @MangelMaxime
    Dropdown.Item.a
        [
            Dropdown.Item.Props
                [
                    OnClick (fun _ ->
                        dispatch (Add p)
                    )
                ]
        ]
        [
            str p
        ]
    We should probably add Dropdown.Item.OnClik helpers because it's common that people will want to attach OnClick to a dropdown item.
    Steffen Forkmann
    @forki
    really don't understanf how it works with elmish
    Maxime Mangel
    @MangelMaxime
    Ok, let me write an example in the REPL
    Steffen Forkmann
    @forki
    thank!
    Maxime Mangel
    @MangelMaxime
    ping @forki
    Steffen Forkmann
    @forki
    "You selected: F#"
    Dropdown.Item.Props
    [
    OnClick (fun _ ->
    dispatch (ChangeFavLang language)
    )
    ]
    ahhhh
    thanks!
    Maxime Mangel
    @MangelMaxime
    Your welcome, I guess I should add an example to Fulma documentation :)
    Steffen Forkmann
    @forki
    yes please
    Maxime Mangel
    @MangelMaxime
    It's tracked Fulma/Fulma#247 so I don't forget to do it.
    Ákos Lukács
    @AkosLukacs
    Hi, you can't type test an array's type in Fable, right?
    Or to ask my actual problem: I have a 'T [], and I know that the actual type of that will be one of 5-6 types. How can I test what's in there? Type test the first item? :) I also know there will be at least one item in each array...
    To clarify, the code compiles, but it's always caught by the first match case. Something like this:
                match box data with
                | :? (MyFoo[]) as p ->
                     // this case executes all the time
                | :? (MyOtherType[]) as p ->
                     // never this
    Maxime Mangel
    @MangelMaxime
    @AkosLukacs I don't think you can type test against array. At when looking at the generated code, it's calling a function isArrayLike
    A solution is to use reflection
    let inline test (data : 'T []) =
        let typ = data.GetType()
    
        match typ.GenericTypeArguments.[0].FullName with
        | x when x = typeof<MyFoo>.FullName -> 
            printfn "MyFoo"
        | x when x = typeof<MyOtherType>.FullName -> 
            printfn "MyOtherType"
        | _ ->
            failwith "Not supported type"
    Ákos Lukács
    @AkosLukacs
    Thanks!
    Btw checking the first item in the array does work, but looks ugly with all the casts, this looks nicer!
    Ákos Lukács
    @AkosLukacs
    Ah, no, inline won't work because the code is inside a generic function (context: generic update handler for editing brainless crud tables). So the compiler can't figure out what the types might be.
    Maxime Mangel
    @MangelMaxime
    In order to use reflection API in Fable you either have to inline the function or use a resolver.
    Does this code works for you:
    type DummyType =
        static member test (data : 'T [], [<Inject>] ?resolver: ITypeResolver<'T>) =
            let typ = resolver.Value.ResolveType()
            JS.console.log(typ)
    
            match typ.FullName with
            | x when x = typeof<MyFoo>.FullName -> 
                printfn "MyFoo"
            | x when x = typeof<MyOtherType>.FullName -> 
                printfn "MyOtherType"
            | _ ->
                failwith "Not supported type"
    Please note that we are directly accessible 'T now when doing the reflection.
    So in your case it's directly the type info for MyFoo and MyOtherType
    Ilja Nosik
    @inosik
    @AkosLukacs Do you know all the possible types beforehand? If yes, why don't you model your data that way? E. g.:
    type T =
      | Strings of string array
      | Ints of int array
    Ákos Lukács
    @AkosLukacs
    It's working if I mark the update function as inline too. @MangelMaxime forgot to hit enter yesterday :)
    @inosik that's not a bad idea Since yes, I know all the possible types.
    Maxime Mangel
    @MangelMaxime
    Indeed, if you know the type it's probably safer to use a DUs like that the compiler has your back :)
    Alexander But
    @ButA1
    Hi, I'm trying to implement a sort of Excel-like input table. So far I've done it in a way similar to the Fable REPL spreadsheet example. Unfortunately doing it this way yields poor performance with Internet Explorer. I've talked to Isaac about this and he showed me ag-grid and useMemo. I still need to figure out how to get data from the ag-grid api and I didn't have time to look at useMemo but before I invest too much time I wanted to ask if anybody here already had experience with this.
    Maxime Mangel
    @MangelMaxime
    Hello, I don't know ag-grid, but I do use memo and similar component to optimize my application rendering at work. If you use ag-grid, I guess you won't need memo because, they probably use stateful component by default.
    If you want to know more about optimising react in Fable you can watch this video
    The memo are even explained in it
    And we now have functional component out the box from react