[refactored] _reactiveNextOperator and _reactiveMap to use named args
ClosedPublic

Authored by appsforartists on Oct 6 2017, 1:15 AM.

Details

Summary

This is the first step towards https://github.com/material-motion/material-motion-js/issues/193.

A nice side effect of this change in conjunction with D3392 is that the types on transform don't have to be manually specified - TypeScript can correctly infer them. It also makes calls to reactiveMap more readable, because the second argument is no longer an unnamed dictionary.

As part of this change, the signature of the operation in _reactiveNextOperator is now a higher-order function. The root cause of D3383 was that there was no closure for an individual observer - state was either ephemeral for an individual emission or shared across all observers. By passing emit and values separately, there is now a scope where an operator can store observer-level state. In my next pass at #193, I will update _nextOperator to use this same signature. In fact, I wonder if _nextOperator and _reactiveNextOperator can be merged entirely.

As an additional part of #193, I'm changing the name of dispatch to emit across the codebase. Something that has been emitted can naturally be called an emission. There's no good noun to refer to something that has been dispatched. I expect having an easy way to refer to each item in a stream will make documentation more clear.

I typically abide by the one-small-change-per-diff policy, but since changing to named args is such a massive refactoring, it's a good time to make these smaller changes too. It reduces the number of refactoring passes over the codebase.

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 6 2017, 1:15 AM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptOct 6 2017, 1:15 AM
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 completed building Restricted Buildable.Oct 6 2017, 1:18 AM
featherless accepted this revision.Oct 6 2017, 2:10 PM
featherless added a subscriber: featherless.

Named args are way better. 👍

This revision is now accepted and ready to land.Oct 6 2017, 2:10 PM
This revision was automatically updated to reflect the committed changes.