[refactored] spring to passthrough initialValue
ClosedPublic

Authored by appsforartists on Oct 2 2017, 9:22 PM.

Details

Summary

A spring is typically attached to a property, which will need an initial value before the spring activates. Presently, the spring only dispatches values when the spring is active (during an animation). This makes it difficult to use, because the initial value must be maintained in two places - in the property that a spring is writing to and as the initialValue for the spring itself. For instance:

const initialOpacity = .5;
const opacitySpring = new NumericSpring();
opacitySpring.initialValue = initialOpacity;
opacitySpring.value$.startWith(initialOpacity).subscribe(…)

With this change, writes to initialValue$ are passed through to value$. Thus, the example can be simplified to:

const opacitySpring = new NumericSpring();
opacitySpring.initialValue = .5;
opacitySpring.value$.subscribe(…)

state$ is not affected by changes to initialValue$. It reflects whether a spring is in motion. Even when it's at rest, changes to initial value will be written to value$.

Diff Detail

Repository
R13 material-motion/material-motion-js
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
appsforartists created this revision.Oct 2 2017, 9:22 PM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptOct 2 2017, 9:22 PM
Restricted Application added a project: Material Motion. · View Herald Transcript
Restricted Application added a reviewer: O3: Material JavaScript platform reviewers. · View Herald Transcript
Restricted Application added a reviewer: Material Motion. · View Herald Transcript
Restricted Application failed to build Restricted Buildable!Oct 2 2017, 9:25 PM

Making changes to accommodate _remember()

Restricted Application completed building Restricted Buildable.Oct 3 2017, 12:19 AM
featherless accepted this revision.Oct 6 2017, 2:08 PM
This revision is now accepted and ready to land.Oct 6 2017, 2:08 PM
This revision was automatically updated to reflect the committed changes.