fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子
this._tick里调用this.changeDetectorRef.detectChanges():
首先从RootViewRef开始检测:
context里能看到Component的数据:
renderComponentOrTemplate:
refreshView里会调用init和check hook:
/*** Executes post-order init and check hooks (one of AfterContentInit, AfterContentChecked,* AfterViewInit, AfterViewChecked) given a view where there are pending init hooks to be executed.* @param lView The LView where hooks are defined* @param hooks Hooks to be run* @param initPhase A phase for which hooks should be run* @param nodeIndex 3 cases depending on the value:* - undefined: all hooks from the array should be executed (post-order case)* - null: execute hooks only from the saved index until the end of the array (pre-order case, when* flushing the remaining hooks)* - number: execute hooks only from the saved index until that node index exclusive (pre-order* case, when executing select(number))*/
function executeInitAndCheckHooks(lView, hooks, initPhase, nodeIndex) {ngDevMode &&assertNotEqual(initPhase, 3 /* InitPhaseCompleted */, 'Init pre-order hooks should not be called more than once');if ((lView[FLAGS] & 3 /* InitPhaseStateMask */) === initPhase) {callHooks(lView, hooks, initPhase, nodeIndex);}
}
使用Directive实例调用hook:
function rememberChangeHistoryAndInvokeOnChangesHook() {const simpleChangesStore = getSimpleChangesStore(this);const current = simpleChangesStore === null || simpleChangesStore === void 0 ? void 0 : simpleChangesStore.current;if (current) {const previous = simpleChangesStore.previous;if (previous === EMPTY_OBJ) {simpleChangesStore.previous = current;}else {// New changes are copied to the previous store, so that we don't lose history for inputs// which were not changed this timefor (let key in current) {previous[key] = current[key];}}simpleChangesStore.current = null;this.ngOnChanges(current);}
}
ngOnChanged hook被调用的前提是,从getSimpleChangesStore返回的simpleChangesStore里的current字段不为空:
更多Jerry的原创文章,尽在:“汪子熙”:
fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子相关推荐
- fixture.detectChange开始单步调试,如何执行到Directive的ngAfterViewInit钩子
同ngOnChanges hook的调用入口一致,请查看这篇文章:fixture.detectChange开始单步调试,如何执行到Directive的ngOnChange钩子. refreshView ...
- Angular jasmine如何从detectChange触发refreshView进而执行到Component的hook实现
触发RefreshView: refreshView的方法实现里,会多处调用executeCheckHook方法: 每个待执行的hook方法的名称都能在注释里找到: 例如:execute pre-or ...
- Python如何实现单步调试
Python如何实现单步调试 https://www.cnblogs.com/jing1617/p/9396617.html https://www.cnblogs.com/xiaohai2003ly ...
- 从ngrx store里selector出来的Observable,执行subscribe的单步调试
源代码: getNextPageContext(): Observable<PageContext> {const a = this.store.pipe(select(RoutingSe ...
- linux下gdb单步调试
用 GDB调试程序 GDB 概述 ---- GDB 是 GNU开源组织发布的一个强大的 UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像 VC. BCB等 IDE的调试,但如果你是在 ...
- ARM DS-5单步调试ARM64 linux 内核
目录 1 介绍 2 开发环境 3 准备工作 3.1 Ubuntu环境准备 3.2 源代码准备 3.3 DS-5准备 3.4 使用DS-5调试源码 3.4.1 建立源码工程 3.4.2 创建debug配 ...
- C语言简单的单步调试
C语言中的单步跟踪调试 单步调试是指程序开发中,为了找到程序的bug,通常采用的一种调试手段,一步一步跟踪程序执行的流程,根据变量的值,找到错误的原因. 下面以一个简单的小程序为例,这里的程序必须是在 ...
- java的单步调试_Eclipse调试Java程序 可用于单步调试
在Eclipse中交互式运行代码是其最强大的特性之一,使用JDT调试器,你可以逐行执行你的Java程序,检查程序不同位置变量的值,这个过程在定位代码中的问题时非常有用. 为了准备调试,你需要在代码中设 ...
- c语言 vc 单步调试方法,VC6断点调试技巧
在第一篇中,我们为大家介绍了如何用VC6进行断点调试,可以实现程序的分步执行.今天我们将继续深入,进行更多断点调试的学习. 首先,写一个例子程序: #include int fun() { print ...
最新文章
- 从多维度解析神经科学中的视觉编码
- MyBatis3: There is no getter for property named 'code' in 'class java.lang.String'
- 创建原生JS insertafter()方法实现
- 【PC工具】更新文件夹多文件群体比较工具WinMerge
- LLBLGen update table with join
- life at University of Liverpool
- 睢县职教中心计算机专业18年高考 成绩,南模18年高考成绩喜人!想进这所学校,你需要知道这些~...
- 删除 Mac AppStore 正在下载的应用
- LeetCode 931. 下降路径最小和(动态规划)
- Elasticsearch aggregations API
- linux下查看内存频率,内核函数,cpu频率
- mssql-sqlserver入门必备知识收集
- Kotlin实战【四】迭代事物:while和for
- 南阳理工acm 1007GCD
- 常用软件滤波方法及其示例程序
- h5优秀控件_7个效果震憾的HTML5应用组件
- Vue开发后台管理系统
- 《mysql入门很简单》_《MySQL入门很简单》练习6.9
- 本人开始提供NOD32 相关升级及咨询服务
- nrf52832 --- 看门狗