PendingTasks
Service that keeps track of pending tasks contributing to the stableness of Angular
application. While several existing Angular services (ex.: HttpClient) will internally manage
tasks influencing stability, this API gives control over stability to library and application
developers for specific cases not covered by Angular internals.
add
() => voidAdds a new task that should block application's stability.
() => voidrun
voidRuns an asynchronous function and blocks the application's stability until the function completes.
pendingTasks.run(async () => { const userData = await fetch('/api/user'); this.userData.set(userData);});
() => Promise<unknown>The asynchronous function to execute
voidDescription
Service that keeps track of pending tasks contributing to the stableness of Angular
application. While several existing Angular services (ex.: HttpClient) will internally manage
tasks influencing stability, this API gives control over stability to library and application
developers for specific cases not covered by Angular internals.
The concept of stability comes into play in several important scenarios:
- SSR process needs to wait for the application stability before serializing and sending rendered HTML;
- tests might want to delay assertions until the application becomes stable;
Usage Notes
const pendingTasks = inject(PendingTasks);const taskCleanup = pendingTasks.add();// do work that should block application's stability and then:taskCleanup();

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
