RxJS - Transformation Operator expand



The expand operator takes in a function as an argument which is applied on the source observable recursively and also on the output observable. The final value is an observable.

Syntax

expand(recursive_func:observable): Observable

Parameters

recursive_func − A function is applied to all the values coming from the source and returns an Observable.

Return value

An observable, with values as per the result of the recursive_func.

Example

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));

Output

expand Operator
Advertisements