차이점이 있습니까?
var source1 = Rx.Observable.of(42);
const oneSubscription = source1.subscribe({
next: x => console.log(x)
});
oneSubscription.unsubscribe();
과
var source2 = Rx.Observable.of(42);
source2.forEach(x => console.log(x));
약속을 만들려면 먼저 구독해야한다고 생각했습니다.
그러나 경우에는 source2
구독하지 않고 작동합니다.
누군가 ca 설명 할 수 있습니다.
forEach
내부적으로도 구독 하기 때문 입니다.
/**
* Subscribes an o to the observable sequence.
* @param {Mixed} [oOrOnNext] The object that is to receive notifications or an action to invoke for each element in the observable sequence.
* @param {Function} [onError] Action to invoke upon exceptional termination of the observable sequence.
* @param {Function} [onCompleted] Action to invoke upon graceful termination of the observable sequence.
* @returns {Diposable} A disposable handling the subscriptions and unsubscriptions.
*/
forEach(observer: IObserver<T>): IDisposable;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다