如果我能理解,
this.store.select
是可观察的。这取决于后面可观察到的类型
this.store.select(本店选择)
但是你可以订阅一个observate来获取值。不需要
pipe
和
mergeMap
.
this.store.select(selectUser).subscribe(
(currentUser: CurrentUser) => { // <-- here you will get the new value
this.localid = currentUser.id; // <-- and you can assign it
}
)
使用您的代码:
this.store.select(selectUser)
.pipe(
mergeMap((currentUser: CurrentUser) => {
return currentUser.id; //return value to the subscribers
}), shareReplayUntil(this.destroySub)
).subcribe(id => this.localid = id); // because of the mergeMap we get the id directly