Ratings act -> let ( ratings, effect ) = Ratings.update act model.ratings in ( { model | ratings = ratings }, Cmd.map Ratings effect )
UserInfo act -> let ( userInfo, effect ) = UserInfo.update act model.app in ( { model | userInfo = userInfo }, Cmd.map UserInfo effect )
Ratings act -> let ( ratings, effect ) = Ratings.update act model.ratings in ( { model | ratings = ratings }, Cmd.map Ratings effect )
UserInfo act -> let ( userInfo, effect ) = then Cmd.batch [ Cmd.map UserInfo effects, Cmd.message (Ratings Reload) ] else Cmd.map UserInfo effects in ( { model | userInfo = userInfo }, cmd )
I feel it will be too messy to keep all this inter-triplet logic here. Is there a better way? Maybe something similar to pub/sub or I'm fundamentally wrong here?
(In the UserInfo "update" function if cannot return a command(effect) "Ratings Reload" directly, because of this "Cmd.map UserInfo effect")
--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
type Action = Loaded | UserInfo UserInfo.Action | Ratings Ratings.Action
@Rupert SmithYour module for pub/sub looks great! I will be useful for a lot of people like me. I think you should publish it.
Can you add a README or provide few examples how to use it properly?
@Rupert Smith
Can you add a README or provide few examples how to use it properly?
I think there is a case to be made for a pub/sub message effects module to become part of the core language though.
I feel it will be too messy to keep all this inter-triplet logic here. Is there a better way? Maybe something similar to pub/sub or I'm fundamentally wrong here?
I know that Elm doesn't have the concept of components but instead it has triplets. They should behave similar to components, they encapsulate internal implementations. I use this concept in my App and I faced some architectural questions.
What is the proper or better way to communicate between triplets without breaking encapsulation?
For example, let say I have two "widgets", UserInfo and Ratings.
In main "update" function I have this
I have a button "Login" in the UserInfo widget. It will call backend API and return the user state.Then I want to load and update the Rating widget.How and where do this?
Put another way, Elm does not have anything similar to components!
Let's take a step back. I'd like to know more.
- Where does this Login button get reused in the application? Is it always in the same place in the header? Is it scattered throughout every page?
These questions matter to figuring out how best to make it reusable. :)
- Is this a single-page application with multiple routes?
Put another way, Elm does not have anything similar to components!But how about elm-mdl, elm-autocomplete, elm-ui, elm-datepicker, elm-form, elm-sortable-table even spinner elm-spinner? Thay all use theirs model, update, view "triplet" to be reusable and hide implementation details.
And it is differently similar to components and pretty abstracted and reusable.
This "not component" will be used here only once (or more but not now) but should be used in several similar projects.They all will be using the same Identity Service so userInfo(and login/logout) should look and feel similar.
Like Evan said, "it just works different in Elm. We do not think in terms of reusable components." :)
No idea long-term, but I know Evan wants to focus on elm-package and asset management for the next release, so I wouldn't say "never" but I would say "not soon." :)
--
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/WMAhcAGmwfM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elm-discuss...@googlegroups.com.
On Monday, November 28, 2016 at 2:01:34 PM UTC, sergii.k...@zalando.de wrote:I feel it will be too messy to keep all this inter-triplet logic here. Is there a better way? Maybe something similar to pub/sub or I'm fundamentally wrong here?
I've pulled out a message channels pub/sub implementation.
Even more, it is exactly like described here https://gist.github.com/evancz/2b2ba366cae1887fe621 by the author of Elm
Thank you for this example. But I don't see how to properly trigger my "ratings" storage reload action if user state changed.
Even more, it is exactly like described here https://gist.github.com/evancz/2b2ba366cae1887fe621 by the author of Elm
This is a gem. Not seen it before but there are some really useful ideas in there.
It had not occurred to me that we can create record types with a 'hole' in them, which can then be used to compose them together to build larger records, but at the same time we can write functions that just operate on whatever components of the record we choose as the level of abstraction to re-use. I'm talking about the "Reusable Actions" section.
On of the interesting solutions https://github.com/folkertdev/outmessage
another http://package.elm-lang.org/packages/prozacchiwawa/effmodel/2.0.0/
and elm-parts
How would you do this differently?
Even more, it is exactly like described here https://gist.github.com/evancz/2b2ba366cae1887fe621 by the author of ElmThis is a gem. Not seen it before but there are some really useful ideas in there.
It had not occurred to me that we can create record types with a 'hole' in them, which can then be used to compose them together to build larger records, but at the same time we can write functions that just operate on whatever components of the record we choose as the level of abstraction to re-use. I'm talking about the "Reusable Actions" section.Yikes, definitely don't do that! That link is from Elm 0.13 - back when everything was based around Signals, the Elm Architecture did not exist yet, and Evan was still trying out different approaches to figure out what worked best.
2016-12-01 12:23 GMT+01:00 ‘Rupert Smith’ via Elm Discuss <elm-d...@googlegroups.com>:
Its not a solution I would reach for quickly, but decomposing record types and functions over them in this way does seem entirely permissable within the language.
It’s certainly doable/permissible in the language Elm, but it is strongly discouraged by the designer of Elm. There have been several discussions revolving around this in the past, on GitHub and the mailing list(s). Search for something like “record nesting is better than record extension” (that’s Evan’s claim). For example: https://groups.google.com/d/msg/elm-discuss/AaL8iLjhEdU/pBe29vQdCgAJ.