[added] onlyDispatchWithUpstream option to _reactiveMap
ClosedPublic

Authored by appsforartists on Fri, Sep 8, 5:55 PM.

Details

Summary

Because _map takes static values, it only dispatches when the upstream does. For instance:

draggedLocation._map(
  (upstreamValue) => {
    const resistanceFactor = 5;
    return upstreamValue * someEquation(resistanceFactor)
  }
);

If we wanted resistanceFactor to be variable, we could use _reactiveMap:

draggedLocation._reactiveMap(
  (upstreamValue, resistanceFactor) => ...,
  [ resistanceFactor$ ],
)

However, _reactiveMap will call transform and dispatch the result when any of its inputs change. In this case, we only want to dispatch when the upstream does. This diff adds that option.

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.Fri, Sep 8, 5:55 PM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptFri, Sep 8, 5:55 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!Fri, Sep 8, 6:07 PM
appsforartists edited the summary of this revision. (Show Details)Tue, Sep 19, 6:46 PM
featherless accepted this revision.Wed, Sep 20, 5:44 PM
featherless added a subscriber: featherless.
featherless added inline comments.
packages/core/src/operators/foundation/_reactiveMap.ts
43

onlyTransformWhenUpstreamChanges?

This revision is now accepted and ready to land.Wed, Sep 20, 5:44 PM