I think there's been something lost here. I'm suggesting you do:

    Task.sequence [ allYourThings ] |> Task.perform Cmd

And then in the update,

    { model | covers = covers } ! [ storeInJS covers ]

> On Dec 3, 2017, at 7:25 AM, Rafał Cieślak <ravici...@gmail.com> wrote:
> 
> Eric: This is what I meant when I suggested wrapping the URLs with RemoteData 
> <http://package.elm-lang.org/packages/krisajenkins/remotedata/latest>. ;) It 
> does pretty much exactly what you described and I'm thinking about using it 
> anyway, as it seems that it's going to be helpful in other parts of the app 
> as well.
> 
> Brian: As far as I understand your approach, your way of solving that 
> involves sending each new album cover through a port separately, which is 
> okay. I was thinking about sending the whole dict (cache) to JS once I know 
> that I finished downloading all the images.
> 
>  it sounds like you want to save the results you get but cache them for 
> future use through a port 
> 
> More-or-less yes, with the difference that right now the cache lives in Elm 
> and the only thing I want to do outside of Elm is to save it to localStorage 
> so that I can rebuild the cache the next time I reload the app.
> 
> So your approach could certainly work, but I think I'm going to use the 
> second solution and wrap the values in the cache with RemoteData. I think I'd 
> rather have as few interactions with JS as possible – in the second solution 
> I'd pass the cache from JS to Elm through flags and then pass it back from 
> Elm to JS once I finish downloading all images.
> 
> ---
> 
> Obviously we could come up with even more ideas. I think my main gripe was 
> that you can either sequence then batch or just batch, but you can't batch 
> and then sequence, because the API doesn't allow you to do that.
> 
> I haven't given much thought to it, but I feel it's because Task and Cmd have 
> fundamentally different approach to error handling. Adding Task.batch would 
> require either imposing certain semantics of errors (like Task.sequence does) 
> or offering an API that would allow the user to implement error semantics 
> themselves. And I'm not sure how easy of a task the latter thing is.
> 
> Even in JS with promises such sequencing would require some not-quite-elegant 
> solutions.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/elm-discuss/22Tt_p2OpMY/unsubscribe 
> <https://groups.google.com/d/topic/elm-discuss/22Tt_p2OpMY/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to 
> elm-discuss+unsubscr...@googlegroups.com 
> <mailto:elm-discuss+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to