该运算符将给出源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