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

Do things without an effects manager #46

Open
valberg opened this issue Mar 12, 2018 · 6 comments
Open

Do things without an effects manager #46

valberg opened this issue Mar 12, 2018 · 6 comments

Comments

@valberg
Copy link

valberg commented Mar 12, 2018

First of all: elm-phoenix is awesome! It's so easy to work with and the API just makes send - so kudos on that!

It would be very neat if it would become possible to install elm-phoenix using the normal elm package utility. This would mean that we did thinks without using an effects manager.

I have little knowledge of how this should be done, but a discussion on the elm-lang discourse it is said that it should require "minimal modifications": https://discourse.elm-lang.org/t/elm-0-19-from-a-production-perspective/815/7

I'm going to see if I can figure out how this should be done, but any help is highly appreciated

@dustinfarris
Copy link
Contributor

dustinfarris commented Mar 14, 2018

my guess is that this will involve heavy use of ports

@valberg
Copy link
Author

valberg commented Mar 14, 2018

@dustinfarris Right, why is that? What do we need to call through ports? I haven't looked through what the effects manager does just yet :)

@dustinfarris
Copy link
Contributor

@valberg my bad — for some reason i had it in my head that this library was calling phoenix.js directly, but that is not the case.

I skimmed the code really quick, it looks like elm-phoenix is operating as an effects manager in order to internalize its state, without requiring the user to wire up a model/update

So things like this:

handleSocketsUpdate : Platform.Router msg (Msg msg) -> Dict String (Socket msg) -> InternalSocketsDict msg -> Task Never (InternalSocketsDict msg)

will need to be refactored into a bona fide update function. I don't think there will be any API changes as a result, just more initial work for the user to set things up.

@valberg
Copy link
Author

valberg commented Mar 14, 2018

@dustinfarris Great! That sounds doable at least ;)

@norpan
Copy link

norpan commented Aug 23, 2018

Let me know if you need any planning/coding help, testing etc.. We are trying to figure out how to upgrade to 0.19 as soon as possible, to avoid future debt.

Right now it seems we need to use ports no matter what, since there is no websocket package in 0.19.

@norpan
Copy link

norpan commented Aug 27, 2018

Hi again,
I got some inspiration during the week-end and threw together an experiment for Elm 0.19. Check it out if you like..

Basically, I'm using a very simple web socket port driver. The setup is a bit verbose though, because you have to hook everything up just right. Perhaps this can be simplified.

With support for web socket tasks, whatever that would look like, some things may be simplified, for instance, you won't have to provide a ref for your push messages, that could be a message callback instead.

But the basic state machine is done. It has socket connection status, socket retry, heartbeat, and channel join status. The api model is the same as for saschatimme/elm-phoenix, you provide a list of channels to subscribe to based on the model.

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

3 participants