Created
November 14, 2017 16:44
-
-
Save baetheus/fe62f5137621f7a0190c7d91b8fd3dd0 to your computer and use it in GitHub Desktop.
Recursive rxjs mergeMap
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
function repeat(n: number): Observable<number> { | |
return of(n).pipe( | |
mergeMap(o => of(o).pipe( | |
merge(repeat(n+1)) | |
)) | |
); | |
} | |
repeat(0).subscribe(n => console.log('Got me a number', n), e => console.error(e), () => console.log('All done')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This totally stack overflows