问题描述
UpdateFormValue 操作是在更改表单值之前调度的,因此当 UpdateFormValue 完成时无法执行任何操作,因为第一个操作完成得比预期早。请寻求您的帮助。
ngOnInit(): void {
this.store.dispatch(new ShowLoading());
this.actions$.pipe(
ofActionSuccessful(UpdateFormValue),take(1)
).subscribe(() => {
this.store.dispatch(new HideLoading());
});
this.activatedRoute.params.subscribe(
(params: Params) => {
// Fetch by id.
if (params?.id) {
this.store.dispatch(new FetchById(params.id));
}
}
);
}
@Action(FetchById)
fetchById(context: StateContext<ArticlesstateModel>,action: FetchById) {
// Get the data.
this.articleService.fetchArticleById(action.id).subscribe((response: ApiResponse) => {
if (response.isValid() && response.isSuccess()) {
const article: Article = this.getModelData(response).pop();
context.patchState({current: article});
context.dispatch(
new UpdateFormValue({
path: 'articles.form',value: article
}
)
);
}
});
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)