MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / register

Method register

src/common/commontypes/Events.js:243–269  ·  view source on GitHub ↗

* @function Events.prototype.register * @description 在事件对象上注册一个事件。当事件被触发时,'func' 函数被调用,假设我们触发一个事件, * 指定 Bounds 作为 "obj",当事件被触发时,回调函数的上下文作为 Bounds 对象。 * @param {string} type - 事件注册者的名字。 * @param {Object} [obj=this.object] - 对象绑定的回调。 * @param {function} [func] - 回

(type, obj, func, priority)

Source from the content-addressed store, hash-verified

241 * @param {(boolean|Object)} [priority] - 当为 true 时将新的监听加在事件队列的前面。
242 */
243 register(type, obj, func, priority) {
244 if (type in Events && !this.extensions[type]) {
245 this.extensions[type] = new Events[type](this);
246 }
247 if ((func != null) &&
248 (Util.indexOf(this.eventTypes, type) !== -1)) {
249
250 if (obj == null) {
251 obj = this.object;
252 }
253 var listeners = this.listeners[type];
254 if (!listeners) {
255 listeners = [];
256 this.listeners[type] = listeners;
257 this.extensionCount[type] = 0;
258 }
259 var listener = {obj: obj, func: func};
260 if (priority) {
261 listeners.splice(this.extensionCount[type], 0, listener);
262 if (typeof priority === "object" && priority.extension) {
263 this.extensionCount[type]++;
264 }
265 } else {
266 listeners.push(listener);
267 }
268 }
269 }
270
271 /**
272 * @function Events.prototype.registerPriority

Callers 15

onMethod · 0.95
registerPriorityMethod · 0.95
registerProjFunction · 0.80
addProjctionFromWKTMethod · 0.80
mapbox-gl.jsFile · 0.80
registerCoordinateSystemFunction · 0.80
wfFunction · 0.80

Calls 2

indexOfMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected