GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Docs
  • Tutorials
  • Playground
  • Reference
  • code
  • PendingTasks for Server Side Rendering (SSR)

This view

  • Original page
  • New address

GeezerVison is showing next.angular.dev — PendingTasks • Angular

API

    
      class PendingTasks {}
    
    

Adds a new task that should block application's stability.

@returns() => void

A cleanup function that removes a task when called.

Runs 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);
});
@paramfn() => Promise<unknown>

The asynchronous function to execute

@returnsvoid

Description

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();
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.