from, of 차이

lee jae hwan·2022년 9월 18일
0

RxJS

목록 보기
18/21
from([1,2,3]).forEach(console.log);

유사배열객체, promise, 이터러블객체등으로부터 옵저버블객체를 생성한다.

옵저버블객체내 원소들은 더이상 배열구조가 아니고 차례로 존재하는 데이터이며 차례로 방출한다. 비동기데이터가 아니면 동기적으로 수행된다.

of(1,2,3).forEach(console.log);

1,2,3개의 숫자를 가진 옵저버블객체를 생성한다.

of([1,2,3]).forEach(console.log);

배열을 하나의 원소로 간주하여 배열원소 하나를 가진 옵저버블객체가 생성된다.

그러나 of는 deprecated되었다.

scheduled<T>(input: ObservableInput<T>, scheduler: SchedulerLike): Observable<T>
scheduled([1, 2, 3], queueScheduler).forEach(console.log);

Scheduler Types
queueScheduler : 동기
asapScheduler : 동기
asyncScheduler : 비동기
animationFrameScheduler

0개의 댓글