Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 仅当订阅后出现新值时才获取该值_Angular_Typescript_Rxjs_Ngrx - Fatal编程技术网

Angular 仅当订阅后出现新值时才获取该值

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

我正在使用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);
      });
我试图在
.subscribe
之前添加
.publish()
,但无法获得任何值


仅当订阅后出现新值时,如何获取
名称
?谢谢

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

  • 热观测与冷观测
  • 背压(在您的情况下,公差为0)

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

  • 热观测与冷观测
  • 背压(在您的情况下,公差为0)

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

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