Closed nickperkinslondon closed 7 years ago
Well if you check the the source code of Ui.Checkbox
(https://github.com/gdotdesign/elm-ui/blob/development/source/Ui/Checkbox.elm#L37) you can see it's not just boolean value, it can be disabled
or readonly
so it has it's own state, also it's inline with some of the more complex components like Ui.Calendar
or Ui.Chooser
in terms of offering the same API (the traditional TEA).
So, in Elm, a "component" cannot hold it's own state? Which means we have to "host" its state somewhere within our app state, right? This seems more awkward than what I was doing in React. For me and my "List of Things", I ended up having to "bake-in" a Checkbox.Model constructor into my JSON decoder, which doesn't feel right -- I would hope that a UI library would only affect the "view" function. Again, maybe I am doing it wrong -- maybe there is some way to separate UI state from "business" state I will keep trying -- this UI looks great -- thanks for your help
BTW....what is "the traditional TEA" ? ( i tried to google it, but you can imagine what i got...)
I'm talking about the first "The Elm Architecture" (TEA) that was introduced to encapsulate logic into modules where each module consists of:
All components in Elm-UI follows this structure.
This official TEA has been changed recently to this: https://github.com/evancz/elm-sortable-table#the-elm-architecture - moving the state around in messages (which I don't agree with mainly because in certain cases it can lead to race conditions)
Suppose I have a List of Things...
...and I want to render each thing with a Checkbox... The documentation says that I have to put a specific type of data on my model, like this:
That feels strange! I was hoping to keep my Model abstract, and free of any UI dependencies! Why can't my model just use a Bool? Am I doing it wrong?