Created
April 16, 2018 15:49
-
-
Save ajcrites/4df7ff51c9c936495ad0ba799ff92d55 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
import { mergeMap, switchMap, take, mapTo, map } from 'rxjs/operators'; | |
import { fromPromise } from 'rxjs/observable/fromPromise'; | |
import { of } from 'rxjs/observable/of'; | |
import { interval } from 'rxjs/observable/interval'; | |
import { request } from 'universal-rxjs-ajax'; | |
const getIt = () => | |
fromPromise((async () => { | |
await Promise.resolve(); | |
})()).pipe(switchMap(() => request({ url: 'https://api.github.com/users/ajcrites' }) | |
.pipe(map((response: any) => response.response.login)))); | |
interval(10) | |
.pipe(take(2), switchMap(() => getIt())) | |
//.pipe(take(2), switchMap(() => request({ url: 'https://api.github.com/users/ajcrites' }) | |
//.pipe(map((response: any) => response.response.login)))) | |
.subscribe(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment