RxJS - 轉換運算子擴充套件



expand 運算子將一個函式作為引數,該函式遞迴地應用於 source 可觀察物件,也應用於 output 可觀察物件。最終值是一個可觀察物件。

語法

expand(recursive_func:observable): Observable

引數

recursive_func − 一個函式,應用於來自 source 的所有值,並返回一個 Observable。

返回值

一個 observable,具有 recursive_func 結果的值。

示例

import { of } from 'rxjs';
import { expand } from 'rxjs/operators';

let buffered_array = of(2).pipe(expand(x => of(2 * x)));
buffered_array.subscribe(arr => console.log(arr));

輸出

expand Operator
廣告
© . All rights reserved.