我正在尝试从ngrx存储中获取数据,但是一旦订阅完成,它就必须完成,这不会发生
const { selectIds, selectEntities, selectAll, selectTotal } = adapter.getSelectors(state);
this.subscription = this.store.select(selectAll)
.pipe(
finalize(() => {
console.log('completed')
}),
.subscribe(
o => {
//perform some action
},
error => {
console.error(error);
}
);
答案 0 :(得分:0)
如果您想听商店中的某些操作,可以尝试一下,想象一下您想听CREATE_SUCCESS操作,然后在创建实体时进行一些控制
import { Actions, ofType } from '@ngrx/effects';
import * as entityActions from './actions';
constructor(private actions$: Actions) {
this.actions.pipe(
ofType(entityActions.EntityActionTypes.CREATE_SUCCESS)
).subscribe(() => {
// code executed every time there is a success creation action dispatched
})
}