Nhowka / Elmish.Bridge

Create client-server Fable-Elmish apps keeping a single mindset
MIT License
139 stars 17 forks source link

[Question] shorten form of `Bridge.AskServer` #54

Closed lukaszkrzywizna closed 1 year ago

lukaszkrzywizna commented 1 year ago

Hi,

I'm testing RPC (Bridge.Client 6.0.2) functionality along with Bridge.AskServer function. To make it more comfortable to use, I thought about creating a helper like this:

let askServer f arg =
    Bridge.AskServer(fun rc -> f(arg, rc))

// ... usage in an app

type ToServer =
        | GetTodos of unit * IReplyChannel<Todo list>

type Msg =
    | GotTodos of Todo list
    | GotTodosError of exn

let cmd = Cmd.OfAsync.either
                  (Bridge.askServer GetTodos)
                  ()
                  GotTodos GotTodosError

However, during runtime I receive an error: TypeError: Cannot read properties of null (reading 'fullname') (log attached) error.log

Would you happen to have any idea what is the reason for this? Can it be fixed somehow?

Nhowka commented 1 year ago

Hi, @lukaszkrzywizna! Could you try to have the same function as inline? Fable does some injection on the type when needed, and it couldn't inject the correct type information without inlining.

lukaszkrzywizna commented 1 year ago

That was the reason. Big thanks!