【发布时间】:2019-03-31 18:27:34
【问题描述】:
根据来自其他流的值有条件地向流添加去抖动时间
const configuration$ = new Subject().asObservable();
const animation$ = new BehaviorSubject(false).asObservable;
以上来自一些服务
configuration$.pipe(debounceTime(CONSTANTS.DEBOUNCE),sample(interval(CONSTANTS.SAMPLE)));
configuration.subscribe(data=> {
// do the stuff;
});
如果 animation$ 具有真值,则应跳过 debounceTime、sample。
如何从动画$ 中提取值并应用 if else 逻辑。
如果我能做到的话
configuration$.pipe(
animation$ ?
pipe(debounceTime(CONSTANTS.DEBOUNCE),sample(interval(CONSTANTS.SAMPLE))) :
of
);
【问题讨论】:
-
我认为您要的是在
debounceTime之前将animation$添加到流中? -
如果animation$有真值那么就不要去抖动
-
啊,我倒过来了。我在下面修改了我的答案
标签: angular rxjs rxjs-pipeable-operators