angular-redux - @angular-redux 实现
问题描述
我正在我的测试应用程序中实现 redux 来管理应用程序状态,我当前的情况是我需要访问后端服务并在服务成功后将响应更新回我的应用程序状态。从那时起,我实现了将处理命中后端服务并更新与 reducer 分离的应用程序状态的效果。但是在调度操作后没有调用效果请检查所做的配置,如果我遗漏了什么,请建议我。
包.json
"@angular-redux/form": "^9.0.1",
"@angular-redux/router": "^9.0.0",
"@angular-redux/store": "^9.0.0",
"@ngrx/core": "^1.2.0",
"@ngrx/effects": "^6.1.0",
"@ngrx/store": "^6.1.0",
在 app.module.ts 里面
EffectsModule.forRoot([TestEffects])
内部组件(调度)
ngOnInit() {
this.store.dispatch({ type: 'GET_FEEDS' })
}
内部影响 Test.Effects
@Effect()
loadFeeds$: Observable<any> = this.actions$.pipe(
ofType('GET_FEEDS'),
switchMap((action) =>
this.feedService.getFeed().pipe(
map(feeds => console.log("Data received ..." + feeds)),
catchError(error => of(console.log("Error ..." + error))),
)
)
)
解决方案
推荐阅读
- java - 即使字符串匹配,string contains() 方法也会返回 false
- python - 如何以python字符串格式传递整个列表?
- firebase - 在 React Native 中集成 Firebase
- c - SIGSEGV 在某处不应该,没有 NULL 指针
- java - @Transient 变量不使用杰克逊序列化
- java - 使用 try catch 语句检查一个对象是否等于另一个对象
- python - Python Pandas:计算导入数据集的均值、标准偏差并计算缺失值
- java - 如何跨 Android 应用统一转换 XML 布局?
- mysql - 如何根据mysql中的日期获取差异
- performance-testing - 在 loadrunner 中,如果负载生成器之一在结果整理过程中失败,如何整理结果?