RxJS:筛选运算符last

该运算符将给出源Observable发出的最后一个值。

句法

last()

返回值

它返回带有最后一个值的可观察值。

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

let all_nums = of(1, 6, 5, 10, 9, 20, 40);
let final_val = all_nums.pipe(last());
final_val.subscribe(x => console.log("The last value is = "+x));

last()提供所提供列表中的最后一个值。

输出值:40

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

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2021年2月9日 上午11:29
下一篇 2021年2月9日 上午11:33

相关推荐

发表回复

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