Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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_Angular7 - Fatal编程技术网

Angular 更新订阅的数据而不启动另一个周期

Angular 更新订阅的数据而不启动另一个周期,angular,typescript,angular7,Angular,Typescript,Angular7,我正在从ngrx/商店获取数据 我正在订阅数据 this.store.select(somedataList) .subscribe(myList => { myList.propertyA = "a different value"; }); 订阅并更改属性值后,我需要更新存储中的数据 this.store.dispatch(new UpdateSomeDataList(myList)); 一旦我调用“dispatch”,那么“.subscribe”将再次启动,并创建一个

我正在从ngrx/商店获取数据 我正在订阅数据

this.store.select(somedataList)
  .subscribe(myList => {

  myList.propertyA = "a different value";

});
订阅并更改属性值后,我需要更新存储中的数据

this.store.dispatch(new UpdateSomeDataList(myList));
一旦我调用“dispatch”,那么“.subscribe”将再次启动,并创建一个无休止的循环


如何更新数据而不产生无休止的循环?

如果您需要订阅只触发一次,请使用
take(1)/first()
RxJS的操作符

this.store.select(somedataList.pipe(take(1))
在这种情况下,您的订阅将在第一个值之后取消订阅

在订阅同一商店的部分后调用dispatch-这将是循环的,因此您需要重新考虑数据流