Orasund / elm-ui-widgets

Collection of reusable views for elm-ui.
https://orasund.github.io/elm-ui-widgets/
BSD 3-Clause "New" or "Revised" License
85 stars 11 forks source link

Confusing msgMapper in Ellie examples #9

Closed c-mart closed 4 years ago

c-mart commented 4 years ago

This is not a problem with the library per se, more a request for some explanation regarding its usage. In many of the Ellie examples, even the simple ones like Button, there is a msgMapper pattern. The identity function is passed in from the main function, through the view, to the Widget being used.

@julianpistorius and I are having trouble understanding why this pattern is used/needed, and how it works. When we try to avoid using it, we get trapped in a mess of compiler errors related to type annotations. Here is an example of what happens when you try to take the msgMapper out of the Widget.button example.

We have been using elm-ui in Exosphere for a long time and are only now seeing this for the first time. Any links to related information would also be appreciated.

Thank you!

Orasund commented 4 years ago

Sorry for your troubles, that shouldn't have happend.

On line 56 replace msg with Msg to make the Ellie code work.

The msgMapper is used to make the same code work on the website as well as in the Ellie.

The msgMapper-pattern is typically used to pass messages upwards. In Ellie it is not needed so i just pass in the identity.


I would like to keep the msgMapper. It might be good to include a small comment how to remove it. Thanks for pointing this out

Right now I don't have access to a computer, so it might take some time until i'll add said comment.