MCPcopy Create free account
hub / github.com/angular/angular / runTask

Method runTask

packages/core/src/zone/ng_zone.ts:247–255  ·  view source on GitHub ↗

* Executes the `fn` function synchronously within the Angular zone as a task and returns value * returned by the function. * * Running functions via `runTask` allows you to reenter Angular zone from a task that was executed * outside of the Angular zone (typically started via {@link #run

(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[], name?: string)

Source from the content-addressed store, hash-verified

245 * If a synchronous error happens it will be rethrown and not reported via `onError`.
246 */
247 runTask<T>(fn: (...args: any[]) => T, applyThis?: any, applyArgs?: any[], name?: string): T {
248 const zone = (this as any as NgZonePrivate)._inner;
249 const task = zone.scheduleEventTask('NgZoneEvent: ' + name, fn, EMPTY_PAYLOAD, noop, noop);
250 try {
251 return zone.runTask(task, applyThis, applyArgs);
252 } finally {
253 zone.cancelTask(task);
254 }
255 }
256
257 /**
258 * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not

Callers

nothing calls this directly

Implementers 1

NoopNgZonepackages/core/src/zone/ng_zone.ts

Calls 3

scheduleEventTaskMethod · 0.65
runTaskMethod · 0.65
cancelTaskMethod · 0.65

Tested by

no test coverage detected