Last active
March 14, 2019 22:12
-
-
Save cartant/08b991faf3e35487eb7a401f9f545753 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function subsequent<T>( | |
count: number, | |
operator: (source: Observable<T>) => Observable<T> | |
): (source: Observable<T>) => Observable<T> { | |
return (source: Observable<T>) => new Observable<T>(observer => { | |
const published = source.pipe(publish()) as ConnectableObservable<T>; | |
const concatenated = concat( | |
published.pipe(take(count)), | |
published.pipe(operator) | |
); | |
const subscription = concatenated.subscribe(observer); | |
subscription.add(published.connect()); | |
return subscription; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment