File tree Expand file tree Collapse file tree
Cute-JavaScript/Cute-Patterns Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -79,6 +79,11 @@ class Dom {
7979 this .events [event ].push (callback)
8080 }
8181
82+ /**
83+ * 移除事件的观察者
84+ * @param {String} event 订阅的事件
85+ * @param {Function} callback 回调函数(观察者)
86+ */
8287 removeEventListener (event , callback ) {
8388 if (! this .events [event ]) {
8489 return
@@ -128,13 +133,13 @@ class EventChannel {
128133 }
129134
130135 hasSubject (subject ) {
131- return this .subjects [subject] ? true : false
136+ return !! this .subjects [subject]
132137 }
133138
134139 /**
135140 * 订阅的主题
136- * @param {String} subject 主题
137- * @param {Function} callback 订阅者
141+ * @param {String} subject 主题名称
142+ * @param {Function} callback 回调方法
138143 */
139144 on (subject , callback ) {
140145 if (! this .hasSubject (subject)) {
@@ -145,6 +150,8 @@ class EventChannel {
145150
146151 /**
147152 * 取消订阅
153+ * @param {String} subject 主题名称
154+ * @param {Function} callback 回调方法
148155 */
149156 off (subject , callback ) {
150157 if (! this .hasSubject (subject)) {
@@ -159,7 +166,7 @@ class EventChannel {
159166
160167 /**
161168 * 发布主题
162- * @param {String} subject 主题
169+ * @param {String} subject 主题名称
163170 * @param {Argument} data 参数
164171 */
165172 emit (subject , ... data ) {
You can’t perform that action at this time.
0 commit comments