MCPcopy Index your code
hub / github.com/angular/angular / invokeTask

Function invokeTask

packages/zone.js/lib/common/events.ts:216–247  ·  view source on GitHub ↗
(task: any, target: any, event: Event)

Source from the content-addressed store, hash-verified

214 const PREPEND_EVENT_LISTENER_SOURCE = '.' + PREPEND_EVENT_LISTENER + ':';
215
216 const invokeTask = function (task: any, target: any, event: Event): Error | undefined {
217 // for better performance, check isRemoved which is set
218 // by removeEventListener
219 if (task.isRemoved) {
220 return;
221 }
222 const delegate = task.callback;
223 if (typeof delegate === 'object' && delegate.handleEvent) {
224 // create the bind version of handleEvent when invoke
225 task.callback = (event: Event) => delegate.handleEvent(event);
226 task.originalDelegate = delegate;
227 }
228 // invoke static task.invoke
229 // need to try/catch error here, otherwise, the error in one event listener
230 // will break the executions of the other event listeners. Also error will
231 // not remove the event listener when `once` options is true.
232 let error;
233 try {
234 task.invoke(task, target, [event]);
235 } catch (err: any) {
236 error = err;
237 }
238 const options = task.options;
239 if (options && typeof options === 'object' && options.once) {
240 // if options.once is true, after invoke once remove listener here
241 // only browser need to do this, nodejs eventEmitter will cal removeListener
242 // inside EventEmitter.once
243 const delegate = task.originalDelegate ? task.originalDelegate : task.callback;
244 target[REMOVE_EVENT_LISTENER].call(target, event.type, delegate, options);
245 }
246 return error;
247 };
248
249 function globalCallback(context: unknown, event: Event, isCapture: boolean) {
250 // https://github.com/angular/zone.js/issues/911, in IE, sometimes

Callers 1

globalCallbackFunction · 0.85

Calls 2

handleEventMethod · 0.80
invokeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…