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 upCandidate fix for #595 #685
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Aug 8, 2016
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Aug 8, 2016
|
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
lukewestby
referenced this pull request
Aug 9, 2016
Closed
Ports do not register immediate `send` #595
knewter
reviewed
Aug 9, 2016
src/Native/Platform.js
| if (!onEffectsCalled) { | ||
| onEffectsCalled = true; | ||
| enqueuedBeforeSetup.forEach(internalSend); | ||
| enqueuedBeforeSetup = null; |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 9, 2016
Member
Switch to use the style in all the rest of the JS. Notice that { is always brought down a line. Notice that } else { is always split onto three lines. Also, can we switch forEach out for a for loop? I'm not sure how old forEach is and I avoid things like this in the JS I write or generate as much as possible.
|
Switch to use the style in all the rest of the JS. Notice that |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 9, 2016
Member
There are two alternate approaches.
- There is no such thing as
onEffectsCalled, onlyqueue = []. If it isinstanceof Arrayyou push values on it. If you send all the things, you switchqueueto benullorundefinedor something. This way there's no potential for synchronization issues between two different variables. - Rather than having ifs, switch between two different send functions. The first one queues things. When it's time to switch, you send all the things and switch to the real send function.
Why is your approach better than these?
|
There are two alternate approaches.
Why is your approach better than these? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukewestby
Aug 9, 2016
Member
Of the option we posted and the two alternatives I think alternative 2 is the best approach. It has the same benefit as alternative 1 of limiting the potential for variables to become out of sync and it also allows for the onEffects and send implementations in use for the majority of the application's lifetime to not need to check some condition that will never be relevant again.
I'll for sure change the forEach to a loop - forEach isn't present in IE8.
|
Of the option we posted and the two alternatives I think alternative 2 is the best approach. It has the same benefit as alternative 1 of limiting the potential for variables to become out of sync and it also allows for the I'll for sure change the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Cool. Also, thanks for figuring this out and working on the PR! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukewestby
Aug 9, 2016
Member
No problem! It seems to be affecting a number of people and I got to hang out and code with @yjkogan for a couple hours
Updates coming shortly
|
No problem! It seems to be affecting a number of people and I got to hang out and code with @yjkogan for a couple hours Updates coming shortly |
added some commits
Aug 9, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yjkogan
commented
Aug 10, 2016
|
Looks awesome! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 10, 2016
Member
Cool :) The solution feels a little tricky, but I think that's inherent to the problem. I.e. This seems like the best way to do a hard thing. Point is, thanks @lukewestby and @yjkogan for sorting this one out! :D (Also hi!)
Do you think it makes sense to do 4.0.5 to get this out as quick as possible? I'll have to look back and see if there are any other changes on master, but that seems like the way to go to me.
|
Cool :) The solution feels a little tricky, but I think that's inherent to the problem. I.e. This seems like the best way to do a hard thing. Point is, thanks @lukewestby and @yjkogan for sorting this one out! :D (Also hi!) Do you think it makes sense to do 4.0.5 to get this out as quick as possible? I'll have to look back and see if there are any other changes on master, but that seems like the way to go to me. |
evancz
merged commit efe096f
into
elm:master
Aug 10, 2016
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
knewter
Aug 10, 2016
It's not urgent at all because you can always do a setTimeout(fn(){}, 0), it's just nice to keep new people from seeing the confusing result.
knewter
commented
Aug 10, 2016
|
It's not urgent at all because you can always do a |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Aug 10, 2016
Member
Eh, I just looked through the commits on master, and this is the only thing since 4.0.4 so I decided to just publish it. If you install things now, it should be 4.0.5 and this should be fixed.
Talk about it here if there are further issues. Otherwise, great work! :)
|
Eh, I just looked through the commits on master, and this is the only thing since 4.0.4 so I decided to just publish it. If you install things now, it should be 4.0.5 and this should be fixed. Talk about it here if there are further issues. Otherwise, great work! :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
yjkogan
Aug 11, 2016
Woohoo! Late to the party but same as @knewter. It was easy to work-around once we found the issue but I think this makes the logic simpler (and lets our site load/paint faster!)
yjkogan
commented
Aug 11, 2016
|
Woohoo! Late to the party but same as @knewter. It was easy to work-around once we found the issue but I think this makes the logic simpler (and lets our site load/paint faster!) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bipvanwinkle
commented
Aug 12, 2016
|
Thank you all for taking time to work on this issue! |
lukewestby commentedAug 8, 2016
This PR demonstrates one possible way to deal with calls to send prior to incoming ports being ready ( #595 ). As @artisonian mentioned,
sendcan be called beforeonEffectsin the port effect manager is called, so there are noSubs around to handle the send. This fix demonstrates queuing things that are sent untilonEffectshas been called for the first time, and then pushing all enqueued values through during that first call.By @yjkogan and myself.
We demonstrated that this fixes the issue in https://github.com/lukewestby/elm-port-bootup-sscce