generate
signature: generate(initialStateOrOptions: GenerateOptions, condition?: ConditionFunc, iterate?: IterateFunc, resultSelectorOrObservable?: (ResultFunc) | SchedulerLike, scheduler?: SchedulerLike): Observable
generate(initialStateOrOptions: GenerateOptions, condition?: ConditionFunc, iterate?: IterateFunc, resultSelectorOrObservable?: (ResultFunc) | SchedulerLike, scheduler?: SchedulerLike): Observable
지정된 스케줄러를 사용하여 반복문을 실행하여 옵저버블을 만들어냅니다.
예시
예시 1: 옵저버블 만들어내기
( StackBlitz )
// RxJS v6+
import { generate } from 'rxjs';
generate(2, x => x <= 8, x => x + 3).subscribe(console.log);
/*
결과:
2
5
8
*/
예시 2: result selector를 사용해서 옵저버블 만들어내기
( StackBlitz )
// RxJS v6+
import { generate } from 'rxjs';
generate(2, x => x <= 38, x => x + 3, x => '.'.repeat(x)).subscribe(
console.log
);
/*
결과:
..
.....
........
...........
..............
.................
....................
.......................
..........................
.............................
................................
...................................
......................................
*/
관련된 사용법
추가 자료
:newspaper: - 공식 문서
:file_folder: Source Code: https://github.com/ReactiveX/rxjs/blob/master/src/internal/observable/generate.ts
Last updated
Was this helpful?