I want to build a “widget package”. The idea is that users, instead of transforming their model into Html, write “view” functions that produce widgets with some predefined behavior.
I found the elm-playground package and thought I could use it as a blueprint for how to set up my package, generally.
Now, I try to figure out the best way to lift messages from my “widget layer” to the user’s types.
Let me try to explain what I mean by example.
The playground features a “Shape” type, with a non-exposed Form type underneath. One shape you can create is a “group” of shapes that puts shapes together:
group : List Shape -> Shape
Imagine I want to add the behavior that allows users to add a copy of the currently focused shape to the group by pressing ENTER.
What would be the best way to achieve that?
Is it best to use the Browser.Events subscription to isKeyDown and enhance the playground model to keep track of the currently focused shape?
Or should each shape have a HTML.Event handler for
on "key" ... to send the message to add a copy of the current shape?
In either case, how to propagate such a message from playground to user code?
I looked at elm-parts, but couldn’t yet wrap my head around if this can be combined with elm-playground to achieve the message lifting.