import { Observable, of, range, from } from 'rxjs';
import { delay, mergeMap, timeInterval, concatMap } from 'rxjs/operators';
contador:number = 0;
// Esto funcionó
range(1,100).pipe(
mergeMap(i => of(i).pipe(delay((i+1)*100))), timeInterval()
).subscribe(i => {
this.contador++;
})
// Otro que no funcionó
Observable.create(obs => {
obs.next(range(1,100));
obs.complete();
}).pipe(
mergeMap((x: [any]) => from(x)),
concatMap(x => of(x).pipe(delay(100)))
)
.subscribe(x => this.contador = x);
range(1,100).pipe(map(row => row), delay(2000)).subscribe(row => {
this.contador++;
})
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.