Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPort Subscription Not working on initial load on 0.17 #582
Comments
This was referenced May 6, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
schnittchen
May 15, 2016
I have the same problem here, and it sometimes works and sometimes doesn't.
I debugged around a bit and found this: Stepping into the port send has subs an empty (Elm) list here https://github.com/elm-lang/core/blob/master/src/Native/Platform.js#L547
Maybe @knowthen can confirm this observation.
schnittchen
commented
May 15, 2016
|
I have the same problem here, and it sometimes works and sometimes doesn't. I debugged around a bit and found this: Stepping into the port Maybe @knowthen can confirm this observation. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
CumpsD
May 16, 2016
Same here, subs is empty, working around it with setTimeout(function(){ app.ports.jsMsgs.send(1); }, 0) for now, then they aren't empty
CumpsD
commented
May 16, 2016
|
Same here, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
PhilippMeissner
May 18, 2016
For the moment you might be happy using programWithFlags like the TodoMVC did. That's what I did as a momentarily workaround.
Here's the documentation: http://package.elm-lang.org/packages/elm-lang/html/1.0.0/Html-App#programWithFlags
Here's it in action :
https://github.com/evancz/elm-todomvc/blob/master/Todo.elm#L86
https://github.com/evancz/elm-todomvc/blob/master/index.html#L17
Hope that helps you out for the moment. Obviously this issue still needs to be looked into.
PhilippMeissner
commented
May 18, 2016
|
For the moment you might be happy using Here's it in action : Hope that helps you out for the moment. Obviously this issue still needs to be looked into. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Going with #595 as a simpler example. |
knowthen commentedApr 30, 2016
Background: I was trying to pull in a JWT from localstorage using ports and I'm unable to do it on initial page load.
Summary: Elm Msg via port subscription, not generated on initial load, however it does work when triggered via button press
To provide a simplified example, I took the source from the interop section of the gitbook and slightly modified it as follows:
I put a console.log into the javascript side and I can see that the handler on the js side is getting called
however the response
app.ports.suggestions.send(suggestions);doesn't seem to create message on the elm side.Oddly if I click the "check" button, a message (from the subscription) is created.
Here's a repo with the code demonstrating the apparent bug: https://github.com/knowthen/portbug