在rxjs-Stream中,我想有条件地插入数据,延迟,然后是原始事件.
from(Array(10).keys())
.pipe(
map(i => ({ data: i })),
concatMap(e => {
if (e.data === 3) {
return of(e)
.pipe(
delay(500),
);
}
return of(e);
}),
)
.subscribe(i => console.log(i));
这会在{ data: 3 }
之前产生延迟.
但我想emits { data: 'a' }
,延迟,{ data: 3 }
.