Last active
November 29, 2017 01:26
-
-
Save jhusain/fe7db6efd31b53e8f0fc58d1e7f4e6df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Observable<T, E> { | |
// cant be typed in flow, but perhaps we can | |
// somehow declare several overloads? | |
// pipe(Observable<T0, E0> => Observable<T1, E1>): Observable<T1, E1> | |
// pipe(Observable<T0, E0> => Observable<T1, E1>, Observable<T1, E1> => Observable<T2, E2>): Observable<T2, E2> | |
// etc... | |
pipe(...operators) { | |
return operators.reduce((acc, curr) => curr(acc), this); | |
} | |
} | |
// example: outputs an Observable of 2,3,4 | |
Observable. | |
of(1,2,3). | |
// map returns Observable<T, E> => Observable<R, E> (faking partial application in JS) | |
pipe(map(x => x + 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment