[changed] types on combineLatest to be more precise
ClosedPublic

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

Details

Summary

Arrays are generic with one parameter in TypeScript - every member has the same type. The original types for combineLatest also treated dictionaries like every member had the same type. In actuality, that is not the precise constraint.

combineLatest takes an array or dictionary of streams and returns a stream of arrays or dictionaries of those streams' values. It doesn't care if the types of the members of the dictionary are heterogeneous. This change expresses that constraint when combineLatest receives a dictionary.

const example: Observable<{ a: number, b: string, c: number }> = combineLatest({ a: number$, b: string$, c: 123 });

Simplifying the type signature also makes specifying the generics easier:

combineLatest<Point2D, MaybeReactive<Point2D>>
// vs
combineLatest<number, Dict<Observable<number>>, Point2D>

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:02 AM
Restricted Application completed building Restricted Buildable.Oct 6 2017, 1:02 AM
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptOct 6 2017, 1:02 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:05 AM
featherless accepted this revision.Oct 6 2017, 2:09 PM
This revision is now accepted and ready to land.Oct 6 2017, 2:09 PM