You could try to go with turning the AnimationFrame.times subscription off
(based on the current model) whenever you don’t need it because no
animation is currently running (which you should be able to know from the
current model). Alike to the last example in the
http://noredink.github.io/posts/signalsmigration.html#filter section.
​

2016-07-09 12:33 GMT+02:00 William Bailey <[email protected]>:

> I recently added animations to my game:
>
> deepfinesse.com/demo
>
> From my testing, CPU is 100% even when nothing is animating.  This seems
> to be a consequence of simply adding AnimationFrame.times to my
> subscriptions.  CPU is still 100% if I do nothing but return an unchanged
> model when processing a timer tick (requestAnimationFrame() under the
> covers), per below.
>
> I thought ELM would be slick enough to realize nothing changed in the
> model and not re-render anything.  This touches on "Lazy" stuff, but Lazy
> appears to be associated with the html package only.  I'm not using that,
> rather, my app is pure graphics via evancz/graphics.
>
> Any ideas?
>
> STEP ONE:
>   subscriptions model =
>       Sub.batch
>         [ Mouse.clicks MouseClick
>         , AnimationFrame.times Ticker   <- HERE
>         ]
>
> STEP TWO:
> update : Msg -> Model -> Model
> update msg model =
>   case msg of
>     MouseClick pos ->
>       handleMouseClick pos model
>     Ticker curTime ->
>       stepAnimation curTime model    <- HERE
>
> STEP THREE: just return model for now
> stepAnimation : Time -> Model -> Model
> stepAnimation curTime model =
>    model
>
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to