subscribe()

verb

say it: “sub-SKRYBE” /səbˈskraɪb/

To start an Observable and say what to do with each value it delivers.

What does subscribe() do?

subscribe() starts an Observable and gives it a function to run for each value (plus optional error and complete handlers). Unsubscribe from long-lived streams to avoid leaks.

this.orders$.subscribe({
  next: orders => this.orders = orders,
  error: err => this.message = 'Could not load orders',
});

In a sentence

  • “Nothing loaded until I subscribed to the products Observable.”

Level: Journeyman · More Angular terms at this level

Updated