elm-anima icon indicating copy to clipboard operation
elm-anima copied to clipboard

Caching during animations

Open srikumarks opened this issue 9 years ago • 0 comments

When a system uses animations, you want it to respond to user input at any time. So it looks like caching (see #1) may be near impossible. However, most applications have stable states or at least quite a few stable parts of them. So it ought to be possible to cache these stable parts to avoid them being recomputed. There is little memory overhead since these cached structures would've have been created anyway.

To get this, I think we may need to think of an animatable parameter as a tagged value like -

type Animatable space = Stable space | Transient space
getValue : Animatable space -> space
getValue anim =
    case anim of
        Stable x -> x
        Transient x -> x

All animatables have a current value irrespective of the stability of the value, but the Stable and Transient tags can be used to signal to caches whether the output of a function applied to a set of animatables is worth caching or not.

If we have the various parts of an application generated using such cacheable views, then we can probably get even higher performance than what we have today. The current performance of the virtual dom approach relies on the poor performance of the evolutionary design of the DOM. With more such fine grained caching, we can get near the game-engine kind of approach and performance.

srikumarks avatar Jan 11 '16 04:01 srikumarks