【发布时间】:2020-05-14 22:08:55
【问题描述】:
关于 rxjs 谜题的问题。
我有一个随机数流。 该数字采用 [0-9] 数字。所以流看起来像:
0, 4, 2, 8, 9, 0, 3, 9, ...
如果 5 之后的数字为 9,我想发出 true。换句话说,如果流中出现了对 [5, 9]。
管道应该是什么?
示例代码在这里:
import { interval } from "rxjs";
import { map } from "rxjs/operators";
const numbers =
interval(500).pipe(map(() => Math.floor(Math.random() * 10))); // it takes [0-9] numbers
numbers.pipe(
// what the pipe should be?
).subscribe(console.log);
【问题讨论】:
标签: rxjs