elm-animator
elm-animator copied to clipboard
Example with a sum type model
Hi Matthew, first of all, thanks for the great library. It is great fun to create animations with elm-animator. When I started using elm-animator in my application, it was just for a simple navigation animation that is visible on every page. But lately, I've wanted to add small animations to some of my pages. Since every page has its own model, my top level model type is a sum type, like for example:
type Model =
OverviewModel Overview.Model Session
| DetailModel Detail.Model Session
Now for animations on every page, I can add a field in the session type alias and use the obvious getters and setters to wire up the animation.
But I'm getting stuck when trying to add (for instance) a Animator.Timeline Bool
to one of the Submodels.
To wire up the Animation, I need to use Animator.watching
, which requires a getter/setter for a timeline regardless if it is actually
in current model or not. I could define a setter which would basically work like Maybe.map
, but I cannot define a getter.
Technically I could default in some way, i.e. return Animator.init False
or something.
Is this just a fundamental issue with the way I have chosen to structure my model or is there a way the current (or future!) API of this package could be used to solve my problems?