0

我有一个共享服务的两个组件,并且该服务连接到 NGRX 数据存储。调用NGRX-Data 方法通过Button-Component服务触发请求。有一个通过异步管道订阅的 Observable getByKey()Display-Component

// Observable subscribed with async pipe
identifiers$: Observable<Identifiers> = new Observable<Identifiers>();

// Method called by the `Button-Component`
callApi(key) {
    // When this emits I want to map the value to `identifiers$`
    this.service.getByKey(key);
}

到目前为止,我无法使用Display-Component. 如果我在服务中手动订阅并且entities$商店中的也更新,它会起作用。我可以使用它,但是我需要一些逻辑来存储key我想避免的。

那么如何从 Store 返回的 Observable 映射到其中Display-Component之一呢?

4

1 回答 1

0

存储是所有子模块及其组件的共享,如果您使用它.forRootAppModule则意味着所有应用程序都连接到同一个存储并共享其数据。

在您的情况下,我会检查选择器identifiers$以确保它接收的内容和方式,因为所描述的流程在 ngrx-data 中工作并且不需要任何额外的更改。

于 2020-05-20T18:56:17.553 回答