Hi Rezza,
Will be something like:
import { interval, of } from 'rxjs';
import { startWith, switchMap, take, takeWhile, tap } from 'rxjs/operators';
const post$ = of({ ok: true }); // fake http Post.
const log = console.log.bind(console);
// function that returns a fake http get
const isReady = () => of(Math.random() < 0.5).pipe(startWith(false));
post$
.pipe(
switchMap(r => (r.ok ? interval(500) : of(-1))),
switchMap(r => (r < 0 ? of(false) : isReady())),
tap(log),
takeWhile(r => !r), // am I done?
take(10) // protect me from mistakes.
)
.subscribe();
Or did I miss something in what you needed?
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.