Closed sheganinans closed 1 year ago
As it is now, Elmish.Streams
hook into the view so it can access both the current model and the dispatch function. The server has no view, so I didn't do a similar concept to support the same features.
The bad news is that changes will need to be made. The good news is that they aren't breaking changes.
I'll see what can be done. Can Elmish.Streams
work on the server without changes?
I'm just gonna link in my other issue, since this is fundamentally related: https://github.com/dbrattli/Elmish.Streams/issues/26
How it's done right now in Elmish.Streams
is that uses websockets explicitly, serialization with Thoth.Json
hooks into AspNetCore
's middlewares:
https://github.com/dbrattli/Elmish.Streams/blob/master/AspNetCore.Middleware/StreamsMiddleware.fs
The relevant example is Magic
example, which is essentially the Time Files Like An Arrow example, but with toggles for things like local and remote:
https://github.com/dbrattli/Elmish.Streams/blob/master/examples/Magic/src/Client/Utils.fs
https://github.com/dbrattli/Elmish.Streams/blob/master/examples/Magic/src/Shared/Shared.fs
https://github.com/dbrattli/Elmish.Streams/blob/master/examples/Magic/src/Server/Server.fs
I think the simplest way forward would actually be an update of Elmish.Streams.AspNetCore.Middleware
, maybe a Elmish.Bridge
-aware version.
Also, if you don't have the time to do this currently. I'm very motivated right now to get this working. So if you can just get me pointed in the right direction, I'll try to get this working ASAP.
Probably just reimplement the setState
will give a way to attach the stream with little change.
@Nhowka I'm not sure what you mean
Sorry, there is that feature on Elmish that gets called after every update and then is used for rendering the view in the case of Elmish.React
. As it overrides the setState
completely, Elmish.Streams
used the view for attaching it to it, but it should be ok with a setState
based attachment on the BridgeServer
implementation.
Closing, since it seems Elmish.Streams is seemingly not actively developed.
I have a scenario where I am using the
Elmish.Bridge
architecture on the frontend withElmish.Streams
. However this breaks the isomorphism, sinceElmish.Bridge
on the server side usesCmd
s by default, whileElmish.Streams
does not useCmd
s.You may know,
Elmish.Streams
modifies theupdate
function, where instead of generating and returningCmd
s there. There is a new functionstream
that is subscribed toProgram.mkSimple
and what would be done byupdate
withCmd
s, is instead done instream
, decoupled fromupdate
.What would be a simple way to use
Elmish.Bridge
, modified to useElmish.Streams
on the server side?