0
我有兩個流,看起來如下:繼續流之後訂閱
const source1 = Rx.Observable.of([1,2,3,4,5])
.map(() => "I am source 1")
.do((x) => console.log(x));
const sub1 = source1.subscribe((v) => console.log("Subscribe 2"));
const source2 = Rx.Observable.fromEvent(document, 'click')
.do(() => console.log("execute!"))
.switchMapTo(source1)
.do(() => console.log("After switch map."))
.map((x) => "source2");
source2.subscribe((x) => console.log(x));
沒有點擊文件我有以下的輸出:
"I am source 1"
"Subscribe 2"
而且點擊的輸出是:
"execute!"
"I am source 1"
"After switch map."
"source2"
如何強制流source1
通過進一步點擊和繼續流source2
?
我經過以下幾個輸出點擊期望:
"I am source 1"
"Subscribe 2"
"execute!"
"I am source 1"
"After switch map."
"source2"