Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with Elmish.Streams on the server side #18

Closed
sheganinans opened this issue Jun 26, 2019 · 7 comments
Closed

Integration with Elmish.Streams on the server side #18

sheganinans opened this issue Jun 26, 2019 · 7 comments

Comments

@sheganinans
Copy link

I have a scenario where I am using the Elmish.Bridge architecture on the frontend with Elmish.Streams. However this breaks the isomorphism, since Elmish.Bridge on the server side uses Cmds by default, while Elmish.Streams does not use Cmds.

You may know, Elmish.Streams modifies the update function, where instead of generating and returning Cmds there. There is a new function stream that is subscribed to Program.mkSimple and what would be done by update with Cmds, is instead done in stream, decoupled from update.

What would be a simple way to use Elmish.Bridge, modified to use Elmish.Streams on the server side?

@sheganinans sheganinans changed the title Integration with Elmish.Streams Integration with Elmish.Streams on the server side Jun 26, 2019
@Nhowka
Copy link
Owner

Nhowka commented Jun 27, 2019

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?

@sheganinans
Copy link
Author

I'm just gonna link in my other issue, since this is fundamentally related: dbrattli/Fable.Reaction#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.

@sheganinans
Copy link
Author

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.

@Nhowka
Copy link
Owner

Nhowka commented Jun 27, 2019

Probably just reimplement the setState will give a way to attach the stream with little change.

@sheganinans
Copy link
Author

@Nhowka I'm not sure what you mean

@Nhowka
Copy link
Owner

Nhowka commented Jun 29, 2019

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.

@sheganinans
Copy link
Author

sheganinans commented Jan 10, 2023

Closing, since it seems Elmish.Streams is seemingly not actively developed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants