如何将 DataSource 加载方法与 ngrx 存储一起使用?
我有这些问题: 1.当页面加载时,加载方法被调用 2.无限加载 3. 2个请求被发送到服务器而不是1个
如果我直接使用该服务,那么不会有任何问题。
打字稿:
this.ds = new CustomStore({
load: (loadOptions: any) => {
this.myFacade.loadAllRecords(this.filter, loadOptions);
return this.myFacade.records$
.toPromise()
.then(result => {
return result;
});
}
});
this.ds = new CustomStore({
load: (loadOptions: any) => {
this.myFacade.loadAllRecords(this.filter, loadOptions);
return new Promise(resolve => this.myFacade.records$
.pipe(takeUntil(this.unsubscribe$)).subscribe(resolve)).then(result => {
return result;
});
}
});
export class MyFacade {
public records$: Observable<any>;
constructor(private store: Store<State>) {
this.records$ =
this.store.pipe(select(myQuery.getRecords));
}
loadAllRecords(model: myModel, loadOptions?: LoadOptions) {
this.store.dispatch(new LoadRecords(model, loadOptions));
}
}


