You can use a timestamp and withLatestFrom
to decide which values to emit
Here I just filter such that only values that meet your condition pass through.
stream2.pipe(
timestamp(),
withLatestFrom(stream1.pipe(
timestamp(),
startWith({timestamp: 0, value: null})
)),
filter(([s2, s1]) => s2.timestamp - s1.timestamp < 1000),
map(([s2, s1]) => ({
stream1: s1.value,
stream2: s2.value
}))
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…