Angular Component之间的事件通知机制
例子:book manage Component里有个app-search-input控件,通过searchEventEmitter发送事件给自己的searchEventHandler:
search input发送事件:
super是一个subject:
和event listener相关的函数:
/*** Wraps an event listener with a function that marks ancestors dirty and prevents default behavior,* if applicable.** @param {?} tNode The TNode associated with this listener* @param {?} lView The LView that contains this listener* @param {?} listenerFn The listener function to call* @param {?} wrapWithPreventDefault Whether or not to prevent default behavior* (the procedural renderer does this already, so in those cases, we should skip)* @return {?}*/
function wrapListener(tNode, lView, listenerFn, wrapWithPreventDefault) {// Note: we are performing most of the work in the listener function itself// to optimize listener registration.return (/*** @param {?} e* @return {?}*/function wrapListenerIn_markDirtyAndPreventDefault(e) {// Ivy uses `Function` as a special token that allows us to unwrap the function// so that it can be invoked programmatically by `DebugNode.triggerEventHandler`.if (e === Function) {return listenerFn;}// In order to be backwards compatible with View Engine, events on component host nodes// must also mark the component view itself dirty (i.e. the view that it owns)./** @type {?} */const startView = tNode.flags & 2 /* isComponentHost */ ?getComponentLViewByIndex(tNode.index, lView) :lView;// See interfaces/view.ts for more on LViewFlags.ManualOnPushif ((lView[FLAGS] & 32 /* ManualOnPush */) === 0) {markViewDirty(startView);}/** @type {?} */let result = executeListenerWithErrorHandling(lView, listenerFn, e);// A just-invoked listener function might have coalesced listeners so we need to check for// their presence and invoke as needed./** @type {?} */let nextListenerFn = ((/** @type {?} */ (wrapListenerIn_markDirtyAndPreventDefault))).__ngNextListenerFn__;while (nextListenerFn) {// We should prevent default if any of the listeners explicitly return falseresult = executeListenerWithErrorHandling(lView, nextListenerFn, e) && result;nextListenerFn = ((/** @type {?} */ (nextListenerFn))).__ngNextListenerFn__;}if (wrapWithPreventDefault && result === false) {e.preventDefault();// Necessary for legacy browsers that don't support preventDefault (e.g. IE)e.returnValue = false;}return result;});
}
最终被book manage的listener接收到:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
Angular Component之间的事件通知机制相关推荐
- Angular父子Component之间的事件通知机制
例子:product-list为parent Component,product-alert为child Component. (1) child Component里必需的开发 从@angular/ ...
- spring事件通知机制详解
优势 解耦 对同一种事件有多种处理方式 不干扰主线(main line) 起源 要讲spring的事件通知机制,就要先了解一下spring中的这些接口和抽象类: ApplicationEventPub ...
- epoll边缘触发_epoll事件通知机制详解,水平触发和边沿触发的区别
看到网上有不少讨论epoll,但大多不够详细准确,以前面试有被问到这个问题.不去更深入的了解,只能停留在知其然而不知其所以然.于是,把epoll手册翻译一遍,更深入理解和掌握epoll事件处理相关知识 ...
- 使用 Rxjs 解决 Angular Component 之间的通信问题
本文讨论如果两个 Angular Component 彼此不知道对方的存在,并且也没有共享的父子 Component 时,如何进行通信. 在包括 Angular 在内的许多前端框架中,当我们将应用程序 ...
- Spring Event事件发布机制
使用Spring Event优雅实现业务需求. 文章目录 一. 什么是Spring Event 二. 为什么要用Spring Event 三. 使用Spring Event实现邮件发送 一. 什么是S ...
- Android应用程序组件Content Provider的共享数据更新通知机制分析
在Android系统中,应用程序组件Content Provider为不同的应用程序实现数据共享提供了基础设施,它主要通过Binder进程间通信机制和匿名共享内存机制来实现的.关于数据共享的另一个 话 ...
- Poco库使用:事件通知
文章目录 通知中心NotificationCenter 通知队列NotificationQueue 优先级通知队列PriorityNotificationQueue 带时间戳的通知队列TimedNot ...
- Spring IoC 源码系列(三)Spring 事件发布机制原理分析
在 IoC 容器启动流程中有一个 finishRefresh 方法,具体实现如下: protected void finishRefresh() {clearResourceCaches();init ...
- dubbo学习之事件通知实践
目录 实践 dubbo-demo-interface dubbo-demo-xml-provider notify-provider.xml UserNotifyServiceImpl Provide ...
最新文章
- html一半文字一半图片,一个div的子div宽是200高是350 里面怎么让图片显示一半 另外一半文字居中!?...
- 浏览器显示XML文档
- 推荐系统炼丹笔记:阿里边缘计算+奉送20个推荐系统强特
- 『线性空间 整数线性基和异或线性基』
- 老生常谈.优化linux内核参数
- mysql数据库备份及恢复命令mysqldump,source的用法
- Java8 Lambda总结
- Copy-on-Iterate java 代码风格
- 单片机机器周期怎么计算公式_单片机定时器周期计算公式
- HDU-Largest Rectangle in a Histogram-1506 单调栈
- java维护_java配置和维护
- python基础--闭包函数和装饰器
- 把矩阵变为0,1矩阵
- python-网易云简单爬虫
- 史上最详细嵌入式系统设计师修炼手册
- Vue 实现简单的时间轴 时间进度条
- 23种常见设计模式详解
- Linux内核由32位升到64,将Ubuntu从32位版本升级到64位版本
- IDEA使用自带maven还是自行配置maven
- Nt*和Zw*系列函数的区别
热门文章
- Atitit.swift 的新特性 以及与java的对比 改进方向attilax 总结
- 组策略中Run logon scripts synchronously和Run startup scripts asynchronously的区别
- SGU 117 Counting
- MySQL数据类型和Java数据类型对应关系表
- 服务发现比较:Consul vs Zookeeper vs Etcd vs Eureka
- 读书笔记--对象、实例、原型、继承
- mfc怎么显示jpg png图像
- Linux设备模型(总结)
- 讲讲Linq to SQL映射(基础篇)
- asp.net 2.0下嵌套masterpage页的可视化编辑