I gave it a lot of thoughts, asked around, etc. and came to the conclusion 
that it's the right answer! Thanks, I'm going with this.

On Thursday, May 19, 2016 at 11:09:48 PM UTC+2, Nicolas Lawler wrote:
>
> Not sure if this pattern still applies in 0.17 (since the examples that 
> used it have been taken out of the Elm Architecture tutorial), but the way 
> I would've solved this would be to take the config object out of the root 
> model and instead pass it to "EditUser.update" as an extra "Context" 
> argument. The thinking here is that (presumably) your http config isn't 
> being updated in response to user input or external subscriptions, so 
> there's no need to pollute the model with it. You just demand that any 
> consumer of EditUser (Main in this case) provide some way of connecting 
> over http. So you'd have something like this:
>
>
>
> module EditUser exposing (..)
>
> -- Model and Msg omitted because I'm lazy 
>
> type Context =
>   { url : String 
>   , headers : List String
>   -- etc...
>   }
>
> update : Context -> Msg -> Model -> (Model, Cmd Msg)
> update context msg model = 
>   case msg of 
>       -- ... stuff
>       
>       SendRequest -> -- here you'd use the context to create the request 
> and send it off, omitted since I haven't looked at the 0.17 http api
>
>       -- more stuff
>
>
> Again, not sure if this is still the recommended advice for the new 
> release, but I can't think of any obvious reason why it wouldn't suffice. 
>
>
>

-- 
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