As a consequence of how Program.withSubscription is defined:
let withSubscription (subscribe : 'model -> Sub<'msg>) (program: Program<'arg, 'model, 'msg, 'view>) =
{ program with subscribe = subscribe }
The current implementation of Program.withBridge and Program.withBridgeConfig will overwrite any existing subscriptions. Alternatively, if there are subscriptions added after the bridge configuration, the Elmish.Bridge subscriptions will be overwritten and their events will never be received.
So I'm suggesting the following additional functions to be added (bikeshedding welcome):
let inline withBridgeAndSubs
endpoint
(subs : 'model -> (string list * (('msg -> unit) -> IDisposable)) list)
(program : Program<_, 'model, 'msg, _>) =
program
|> Program.withSubscription
(fun model ->
subs model
@ [["Elmish";"Bridge"], fun dispatch -> let config = Bridge.endpoint(endpoint) in config.Attach dispatch; config ])
let inline withBridgeConfigAndSubs
(subs : 'model -> (string list * (('msg -> unit) -> IDisposable)) list)
(config:BridgeConfig<_,_>)
(program : Program<_, 'model, 'msg, _>) =
program
|> Program.withSubscription
(fun model ->
subs model
@ ["Elmish"::"Bridge"::(config.name |> Option.map List.singleton |> Option.defaultValue []), fun dispatch -> config.Attach dispatch; config])
So that the new style of Elmish subscriptions can play nice with Elmish.Bridge
As a consequence of how
Program.withSubscription
is defined:The current implementation of
Program.withBridge
andProgram.withBridgeConfig
will overwrite any existing subscriptions. Alternatively, if there are subscriptions added after the bridge configuration, theElmish.Bridge
subscriptions will be overwritten and their events will never be received.So I'm suggesting the following additional functions to be added (bikeshedding welcome):
So that the new style of
Elmish
subscriptions can play nice withElmish.Bridge