RxJS:联接运算符concat

该运算符将顺序地发出给定的Observable作为输入,然后进行下一个。

语法

concat(observables: Array): Observable

参量

observables-给定的输入是Observables数组。

返回值

一个observable返回一个与源observable的值合并的单个值。

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

let list1 = of(2, 3, 4, 5, 6);
let list2 = of(4, 9, 16, 25, 36)
let final_val = list1.pipe(concat(list2));
final_val.subscribe(x => console.log(x));

输出

我们将两个可观察值合而为一。以下是输出内容:

2 3 4 5 6 4 9 16 25 36

作者:terry,如若转载,请注明出处:https://www.web176.com/rxjs/1815.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2021年2月8日 下午3:02
下一篇 2021年2月8日 下午3:12

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注