Re: [elm-discuss] Managing global state in Elm

2016-12-12 Thread Birowsky
Erik, Mark, thanx a ton for your responses! Erik, I was using that approach solely for the views but you made me think how I might do it in the updates too, which from here, seems like quite the prettification. Thanx for that! Mark, wow, thanx for the effort. If you could believe it, I built t

Re: [elm-discuss] Managing global state in Elm

2016-12-02 Thread Mark Hamburg
To use effects managers or not to use effects managers. The Elm guide basically says "don't" and then proceeds to not provide much documentation about how to write an effects manager if you wanted to. I guess one could take that as a hint. TL;DR You don't need to write effects managers but you wil

Re: [elm-discuss] Managing global state in Elm

2016-12-02 Thread Erik Lott
> > The problem i see with this approach is that in hierarchy of deeply nested > components, the whole ancestry would need to know about the intention of > the leaf. Sort of. Each module only needs to consider it's direct child/children. So, to use a module, you have to use it's API. I under

Re: [elm-discuss] Managing global state in Elm

2016-12-02 Thread Birowsky
The problem i see with this approach is that in hierarchy of deeply nested components, the whole ancestry would need to know about the intention of the leaf. I was hoping towards more of a command-like approach. > On Dec 2, 2016, at 14:45, Erik Lott wrote: > > Birowsky, your leaf component wi

Re: [elm-discuss] Managing global state in Elm

2016-12-02 Thread Erik Lott
Birowsky, your leaf component will need return messages to the parent, and the parent can act on those messages to update it's state. There's no magic to it unfortunately. Do you have a specific problem you're trying to solve? On Wednesday, November 30, 2016 at 12:04:08 PM UTC-5, Birowsky wrote:

Re: [elm-discuss] Managing global state in Elm

2016-11-30 Thread Birowsky
Hey Eric, please elaborate on this one. How do you envision leaf component triggering global state update? > The second problem becomes: *how do we load this global state/business > data into the application and cache it?* This requirement is now fairly > easy to wire-up in elm since the http

Re: [elm-discuss] Managing global state in Elm

2016-08-23 Thread Erik Lott
> > Does Elm have best practices for managing and reconciling state between > components and global application state managers? Yes: don't hold global state in your components' models :) It might help to think about this question differently. Going back to the OP's original question, let's fo

Re: [elm-discuss] Managing global state in Elm

2016-08-23 Thread suttlecommakevin
Great question, OP. I've been wondering about the same thing. React has pretty clear "best practices " when it comes to component vs global state, but it's also not immutable by default

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread Peter Damoc
Tim, thank you for pointing this out. In the interest of clarity I would like to add that ! is not an operator but a function. Elm allows one to define single character functions and if the function name is made of symbols, it can be used inline without backtick marks (you have to declare the nam

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread Tim Stewart
This is a bit pedantic, but over the course of learning Elm I have sometimes found the use of magic symbols a bit confusing. This is the first I heard of the ! operator. In 2 of the three places it is used in the code [1] the ! infix operator is not really shorthand for the tuple form because i

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread Peter Damoc
I'm guessing you referring to: http://package.elm-lang.org/packages/elm-lang/core/4.0.1/Platform-Cmd#! This is the code : (!) : model -> List (Cmd msg) -> (model, Cmd msg) (!) model commands = (model, batch commands) I use it as a short hand for joining the model and the Cmds. It's also pret

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread Simon
This is super cool. But what is the function: (!) : a -> List b -> (a, b) On Wednesday, 1 June 2016 09:45:05 UTC+2, James Wilson wrote: Thanks for your help; I'll have a ponder and probably end up taking an > effect manager route again (I started this way and then ended up with some > weird

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread James Wilson
Thanks for your help; I'll have a ponder and probably end up taking an effect manager route again (I started this way and then ended up with some weird hybrid where my cache was in the main elm app and an effect manager did the "lower level" api stuff; but I'm not so happy with it) As another e

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread Peter Damoc
I haven't used an effect manager for this because I haven put in the time needed to learn how to create effect managers. :) If what I've shown here can be accomplished with an effect manager then that's the way it should be done. :) On Wed, Jun 1, 2016 at 10:21 AM, James Wilson wrote: > T

Re: [elm-discuss] Managing global state in Elm

2016-06-01 Thread James Wilson
Thanks, that looks like basically exactly what I'd have guessed :) It's super useful seeing an actual code sample with these ideas in. One thing I wonder now is; why not use an effect manager for this? It basically seems to fit the exact same space (allows you to create a custom Req like thing

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread Peter Damoc
The updating of the cache sounds to me like this: 1. if we have the info in cache, just supply the info without a HTTP GET 2. if we don't have the info in cache, return a different Msg that encapsulates the msg that requested the original information and the info required for the cache update. He

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread James Wilson
The key part that's not coded in the gist is the use of a cache/global state object, however I think I see what you're getting at - pass back up the chain a Req object, say, and at the top we can turn it into a Cmd using, say, some top level global state as well as whatever other data we need.

Re: [elm-discuss] Managing global state in Elm

2016-05-31 Thread Peter Damoc
ADT in Elm is one of its most powerful weapons. You could encapsulate your requests in a type and use this type at top level to fulfill them. For example: instead of returning Cmd msg you return some Req msg that can be turned into a Cmd msg at top level based on some context information. Here i

[elm-discuss] Managing global state in Elm

2016-05-31 Thread James Wilson
In Elm, each component basically has its own internal state (which is actually all just a slice of one global model). In my app, I also want global state that is independant of any components; for example a clientside cache of various API responses (asset details - there could be many thousands