[fixed] operators to return MotionObservable rather than Observable
ClosedPublic

Authored by appsforartists on Apr 21 2017, 12:45 AM.

Details

Summary

When the operator interfaces had the shape

interface Thingable {
  thing(): Observable<U>
}

TypeScript didn't know if the resulting observable had operators. Thus, stream.thing().otherThing() would error, because otherThing() doesn't exist on Observable.

Diff Detail

Repository
R13 material-motion/material-motion-js
Lint
Lint OK
Unit
No Unit Test Coverage
Restricted Application added a reviewer: O2: Material Motion. · View Herald TranscriptApr 21 2017, 12:45 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
appsforartists edited the summary of this revision. (Show Details)Apr 21 2017, 12:46 AM
Restricted Application failed to build Restricted Buildable!Apr 21 2017, 12:48 AM

Using as any as MotionObservable<> in a few more places

Restricted Application completed building Restricted Buildable.Apr 21 2017, 1:00 AM
Restricted Application failed to build Restricted Buildable!Apr 21 2017, 1:03 AM

Remember how I didn't think this would work because of the circular dependency problem, but couldn't remember the specifics? Here are the specifics:

MotionObservable.ts:20 Uncaught TypeError: operators_1.withMotionOperators is not a function

MotionObservable is imported by the operators. MotionObservable depends on withMotionOperators, which in-turn depends on the operators. So, when the operators load, they refer to a symbol which refers to a function which isn't defined yet. 😢

Using interface rather than concrete type to avoid circular dependency

Restricted Application failed to build Restricted Buildable!Apr 21 2017, 1:42 AM
featherless accepted this revision.Apr 21 2017, 4:27 PM
This revision is now accepted and ready to land.Apr 21 2017, 4:27 PM
This revision was automatically updated to reflect the committed changes.