I am uisng ngrx/store.
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);
});
I tried to add .publish()
before .subscribe
, but then I cannot get any value.
How can I get name
, only if a new value comes after subscribing? Thanks
When you subscribe, the current state of the store will be returned. If you don't want the current state, then you can skip the first response. this.store.select(...).skip(1)