>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 because you mentioned 
localStorage in your initial message. I imagine you'd instead want to leave 
the coordination in Elm to take advantage of Elm's concurrency model 
(immutable data + message-passing) and have a single port to talk to 
JavaScript.

On Monday, October 17, 2016 at 3:03:14 AM UTC-4, David Andrews wrote:
>
> 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 the port API a -> Cmd msg instead of a -> Task Never () or 
>    something like that?
>    2. Is there a recommended way to pass data to ports in order? I've 
>    come up with the workaround of sending over only one port per update and 
>    using Cmd.Extra.message to trigger additional updates immediately, but 
>    I don't think it's very clean.
>    
>
> On Monday, October 17, 2016 at 2:39:01 AM UTC-4, Peter Damoc wrote:
>>
>> On Mon, Oct 17, 2016 at 8:02 AM, Janis Voigtländer <
>> [email protected]> 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 port data sending is 
>>> Cmd-based.
>>>
>> Ooops... my bad. I should have looked more carefully. 
>>
>>
>>
>> -- 
>> There is NO FATE, we are the creators.
>> blog: http://damoc.ro/
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to