Angular 仅当订阅后出现新值时才获取该值
我正在使用ngrx/商店Angular 仅当订阅后出现新值时才获取该值,angular,typescript,rxjs,ngrx,Angular,Typescript,Rxjs,Ngrx,我正在使用ngrx/商店 this.store .select(s => s.products && s.products.name) .filter(name => !!name) .subscribe(name => { // Now if there is a `name` in the store, it will run immediately // However, I want t
this.store
.select(s => s.products && s.products.name)
.filter(name => !!name)
.subscribe(name => {
// Now if there is a `name` in the store, it will run immediately
// However, I want to get the `name`, only if a new value comes after subscribing
console.log(name);
});
我试图在.subscribe
之前添加.publish()
,但无法获得任何值
仅当订阅后出现新值时,如何获取
名称
?谢谢为此,您需要了解以下内容:
- 热观测与冷观测
- 背压(在您的情况下,公差为0)
- 热观测与冷观测
- 背压(在您的情况下,公差为0)
this.store.select(…).skip(1)订阅时,将返回存储的当前状态。如果不需要当前状态,则可以跳过第一个响应。 this.store.select(…).skip(1)