1

我正在使用 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 to get the `name`, only if a new value comes after subscribing
        console.log(name);
      });

.publish()我之前尝试添加.subscribe,但后来我无法获得任何价值。

name仅当订阅后出现新值时,我怎样才能获得?谢谢

4

2 回答 2

4

订阅时,将返回商店的当前状态。如果您不想要当前状态,则可以跳过第一个响应。this.store.select(...).skip(1)

于 2016-06-30T02:08:59.747 回答
0

为此,您需要了解以下内容:

  • 热与冷可观察量
  • 背压(在您的情况下,公差为 0)
于 2016-06-30T01:31:14.523 回答