这个代码是在哪里注册的事件呢?
来源:8-9 -基础类-Actions 依赖注入实现管理滚动动作的逻辑
秋得法
2024-01-08
this.hooks = new EventEmitter([‘start’, ‘scrollStart’, ‘scroll’, ‘scrollEnd’])
这行代码似乎仅仅是生成了下面的数组
eventTypes[{'start':'start'},{scrollStart:'scrollStart'},{scroll:'scroll'},{scrollEnd:'scrollEnd'}]
在Action.ts中
this.hooks.emit(this.hooks.eventTypes.scroll, this.getCurrentPos())
却看到了这个调用,好像没有到上面’start’, ‘scrollStart’, ‘scroll’, 'scrollEnd’这些事件的注册,请问老师这个
this.hooks = new EventEmitter([‘start’, ‘scrollStart’, ‘scroll’, ‘scrollEnd’])
这个代码的意义何在?是在哪里注册的事件呢?
写回答
1回答
-
秋得法
提问者
2024-01-08
Scroller.ts文件中的 `bindActions()` 方法注册了来自文件Action.ts的 `ScrollerActions` 类(在actions.ts文件中定义)的事件。
012024-01-09
相似问题