Nhowka / Elmish.Bridge

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

Update to Elmish v4 #48

Closed OnurGumus closed 1 year ago

OnurGumus commented 1 year ago

Elmish v4 has some changes with subscription, my fix locally looks like below

[<RequireQualifiedAccess>]
module Program =
    /// Apply the `Bridge` to be used with the program.
    /// Preferably use it before any other operation that can change the type of the message passed to the `Program`.
    let inline withBridge endpoint (program : Program<_, _, _, _>) =
        program |> Program.withSubscription (fun _ -> [["withBridge"],Bridge.endpoint(endpoint).Attach])

    /// Apply the `Bridge` to be used with the program.
    /// Preferably use it before any other operation that can change the type of the message passed to the `Program`.
    let inline withBridgeConfig (config:BridgeConfig<_,_>) (program : Program<_, _, _, _>) =
        program |> Program.withSubscription (fun _ -> ( [ ["withBridgeConfig"], config.Attach ]))

And return disposable from attach

image
OnurGumus commented 1 year ago

Serverside is a bit more tricky though.

Nhowka commented 1 year ago

@OnurGumus Could you test the branch elmish-v4 and confirm if that it is working? If there are no issues, I can publish a new NuGet version asap.

OnurGumus commented 1 year ago

@Nhowka Tested and works good. Note I didn't test the dotnet client and my scenario is somewhat basic at the moment :) So please publish.

Nhowka commented 1 year ago

It should be available as soon as nuget finishes processing it. Thank you for the initial testing!