Angular @Effect监听指定Action类型的实现原理
发布日期:2021-06-30 14:34:34
浏览次数:2
分类:技术文章
本文共 965 字,大约阅读时间需要 3 分钟。
Ngrx里action的职责就是express unique events & intents.
源代码:@Effect() searchBookICanbeAnyName$: Observable= this.actions$.pipe( ofType(bookManage.SEARCH), // 监听bookManager.SEARCH action? debounceTime(300), mergeMap((action: bookManage.SearchAction) => { const nextSearch$ = this.actions$.pipe(ofType(bookManage.SEARCH), skip(1)); return this.service.searchBooks(action.payload).pipe( takeUntil(nextSearch$), // If successful, dispatch success action with result map((data: BookResult) => ({ type: bookManage.SEARCH_COMPLETE, payload: data.items})), // If request fails, dispatch failed action catchError(() => of({ type: bookManage.SEARCH_COMPLETE, payload: []})) ); }) );
this.action$是Effect类构造函数参数,被Angular DI框架注入:
effects.js.createEffectInstances:
action$.pipe里传入的三个操作:
(1) ofType - 通过filter operator实现
(2) debounceTime (3) mergeMap这三个operations的运行时结构:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
转载地址:https://jerry.blog.csdn.net/article/details/109048100 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
感谢大佬
[***.8.128.20]2024年05月01日 02时27分53秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
python的ImportError
2019-05-01
centos最小化安装配置网络问题
2019-05-01
linux安装java环境[JDK1.8]
2019-05-01
linux下安装jenkins+git+python
2019-05-01
jenkins直接安装插件包
2019-05-01
CentOS 7系统时间与实际时间差8个小时
2019-05-01
3性能测试简介(什么是性能测试?为什么进行性能测试,性能指标分析)
2019-05-01
5loadrunner脚本优化
2019-05-01
windows10家庭版开启组策略
2019-05-01
windows2008 R2sp1安装loadrunner12
2019-05-01
LoadRunner12浏览器录制(谷歌火狐)
2019-05-01
LoadRunner12——回放脚本
2019-05-01
python多线程_thread与threading(推荐使用)
2019-05-01
【经验分享】XPATH逻辑运算
2019-05-01
python+selenium 浏览器无界面模式运行
2019-05-01
解决uiautomatorviewer中添加xpath的方法
2019-05-01
Windows Server R2 安装python时报策略不允许的解决方案
2019-05-01
pip无法安装:换成国内镜像
2019-05-01
python安装mysqlclient[MySQLdb]
2019-05-01