MCPcopy
hub / github.com/angular/angular / ApplicationRef

Class ApplicationRef

packages/core/src/application/application_ref.ts:254–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

252 */
253@Service()
254export class ApplicationRef {
255 /** @internal */
256 _runningTick: boolean = false;
257 private _destroyed = false;
258 private _destroyListeners: Array<() => void> = [];
259 /** @internal */
260 _views: InternalViewRef<unknown>[] = [];
261 private readonly internalErrorHandler = inject(INTERNAL_APPLICATION_ERROR_HANDLER);
262 private readonly afterRenderManager = inject(AfterRenderManager);
263 private readonly zonelessEnabled = inject(ZONELESS_ENABLED);
264 private readonly rootEffectScheduler = inject(EffectScheduler);
265
266 /**
267 * Current dirty state of the application across a number of dimensions (views, afterRender hooks,
268 * etc).
269 *
270 * A flag set here means that `tick()` will attempt to resolve the dirtiness when executed.
271 *
272 * @internal
273 */
274 dirtyFlags = ApplicationRefDirtyFlags.None;
275
276 /**
277 * Most recent snapshot from the `TracingService`, if any.
278 *
279 * This snapshot attempts to capture the context when `tick()` was first
280 * scheduled. It then runs wrapped in this context.
281 *
282 * @internal
283 */
284 tracingSnapshot: TracingSnapshot | null = null;
285
286 // Needed for ComponentFixture temporarily during migration of autoDetect behavior
287 // Eventually the hostView of the fixture should just attach to ApplicationRef.
288 private allTestViews: Set<InternalViewRef<unknown>> = new Set();
289 private autoDetectTestViews: Set<InternalViewRef<unknown>> = new Set();
290 /** @internal */
291 includeAllTestViews = false;
292 /** @internal */
293 afterTick = new Subject<void>();
294 /** @internal */
295 get allViews(): Array<InternalViewRef<unknown>> {
296 return [
297 ...(this.includeAllTestViews ? this.allTestViews : this.autoDetectTestViews).keys(),
298 ...this._views,
299 ];
300 }
301
302 /**
303 * Indicates whether this instance was destroyed.
304 */
305 get destroyed() {
306 return this._destroyed;
307 }
308
309 /**
310 * Get a list of component types registered to this application.
311 * This list is populated even before the component is created.

Callers

nothing calls this directly

Calls 8

synchronizeMethod · 0.95
injectFunction · 0.90
profilerFunction · 0.90
setActiveConsumerFunction · 0.90
warnIfDestroyedFunction · 0.85
disposeMethod · 0.65
checkNoChangesMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…