如何过滤掉初始值但所有后续值?
how to filter out the initial value but all the subsequent ones?
这个 notificationsCount$
被多个组件调用。这就是为什么我在组件第一次想要读取数据时进行初始调用的原因。
this.initialLoad = false;
readonly notificationsCount$ = this.store.pipe(
select(getNotificationsCount),
tap(() => {
if(!this.initialLoad){
this.initialLoad = true;
this.loadNotifications();
}
}),
skip(1)
);
没有过滤,选择器returning 0,初始值,3,通知数量调用后端后。我希望选择器发出除初始值以外的所有值,即 0.
skip(0) 仍然 returns 两个值,即 0 和 3。skip(1) returns 0。skip(2) 没有 return 任何东西。
感谢您的帮助
有索引参数,您可以 mergeMap/switchMap
计算排放量,并根据索引可以使用 never()
吞下排放量
this.store.pipe(mergeMap((value,index)=>{
if(index<1) return never()
// do you stuff
}))
这个 notificationsCount$
被多个组件调用。这就是为什么我在组件第一次想要读取数据时进行初始调用的原因。
this.initialLoad = false;
readonly notificationsCount$ = this.store.pipe(
select(getNotificationsCount),
tap(() => {
if(!this.initialLoad){
this.initialLoad = true;
this.loadNotifications();
}
}),
skip(1)
);
没有过滤,选择器returning 0,初始值,3,通知数量调用后端后。我希望选择器发出除初始值以外的所有值,即 0.
skip(0) 仍然 returns 两个值,即 0 和 3。skip(1) returns 0。skip(2) 没有 return 任何东西。
感谢您的帮助
有索引参数,您可以 mergeMap/switchMap
计算排放量,并根据索引可以使用 never()
this.store.pipe(mergeMap((value,index)=>{
if(index<1) return never()
// do you stuff
}))