Or how about adding an incoming subscription port when the localStorage
save finishes. Then you could put something in the model to indicate you
are waiting to close. Once the save message comes back, check to see if you
were waiting to close before sending the close message out the other port.
Ahh...I see. Assuming you have some sort of autosave logic, how about two
messages: Save and SaveAndQuit? It seems reasonable to me to split the
actions this way...Save could be scheduled using Time.every and SaveAndQuit
could be both an explicit user interaction and an incoming port message
The problem initially arose when I had two ports, one of which wrote to
local storage and the other of which closed the window. Nothing was ever
written to local storage because the window closed first. The reason I
went with two ports is because those actions are so conceptually different,
and
>From what I can tell, port communication uses Cmd because interop with
JavaScript isn't necessarily a request-response communication pattern
(instead, port are pubsub).
But I do have a question: *Is the underlying problem a need to coordinate
access to a shared resource in JavaScript? *I ask
In another discussion, I was pointed to
http://faq.elm-community.org/17.html#what-is-the-difference-between-cmd-and-task,
which sheds some light on the issue, but also raises a few questions.
Specifically:
1. The article mentions that APIs generally expose Task in favor of Cmd.
Why is
On Mon, Oct 17, 2016 at 8:02 AM, Janis Voigtländer <
janis.voigtlaen...@gmail.com> wrote:
> Peter, the problem in David’s case is that the actions he wants to order
> execution of are port data sending, and there is no “something lower level,
> like Tasks” for that. The only API available for
Peter, the problem in David’s case is that the actions he wants to order
execution of are port data sending, and there is no “something lower level,
like Tasks” for that. The only API available for port data sending is Cmd
-based.
2016-10-15 23:06 GMT+02:00 Peter Damoc :
>
Cmd.batch does not make any guarantee about the order of execution. It is
use to bundle a batch of commands in one entity.
If you need order of execution, you need to use something lower level, like
Tasks where you have `andThen`.
On Thu, Oct 13, 2016 at 9:59 PM, David Andrews