日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Rxjs merge 学习笔记

發布時間:2023/12/19 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Rxjs merge 学习笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

官方鏈接:https://rxjs-dev.firebaseapp.com/api/index/function/merge

Creates an output Observable which concurrently emits all values from every given input Observable.

創建一個輸出 Observable,它同時發出來自每個給定輸入 Observable 的所有值。

merge subscribes to each given input Observable (as arguments), and simply forwards (without doing any transformation) all the values from all the input Observables to the output Observable. The output Observable only completes once all input Observables have completed. Any error delivered by an input Observable will be immediately emitted on the output Observable.

merge 訂閱每個給定的輸入 Observable(作為參數),并簡單地將所有輸入 Observable 的所有值(不做任何轉換)轉發到輸出 Observable。 輸出 Observable 僅在所有輸入 Observable 完成后才完成。 輸入 Observable 傳遞的任何錯誤都將立即在輸出 Observable 上發出。

看一個例子:

import { merge, fromEvent, interval } from 'rxjs';const clicks = fromEvent(document, 'click'); const timer = interval(1000); const clicksOrTimer = merge(clicks, timer); clicksOrTimer.subscribe(x => console.log(x));

輸出:

另一個例子:

import { merge, interval } from 'rxjs'; import { take } from 'rxjs/operators';const timer1 = interval(1000).pipe(take(10)); const timer2 = interval(2000).pipe(take(6)); const timer3 = interval(500).pipe(take(10)); const concurrent = 2; // the argument const merged = merge(timer1, timer2, timer3, concurrent); merged.subscribe(x => console.log(x));// Results in the following: // - First timer1 and timer2 will run concurrently // - timer1 will emit a value every 1000ms for 10 iterations // - timer2 will emit a value every 2000ms for 6 iterations // - after timer1 hits its max iteration, timer2 will // continue, and timer3 will start to run concurrently with timer2 // - when timer2 hits its max iteration it terminates, and // timer3 will continue to emit a value every 500ms until it is complete

輸出:

更多Jerry的原創文章,盡在:“汪子熙”:

總結

以上是生活随笔為你收集整理的Rxjs merge 学习笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。