Jump to content

Observable (Computing)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Dpradeepc (talk | contribs) at 08:22, 11 June 2019 (Created page with 'An observable is one of the key components of reactive programming and was a proposed standard for managing asynchronous data in ECMAScript 2017. An obse...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

An observable is one of the key components of reactive programming and was a proposed standard for managing asynchronous data in ECMAScript 2017. An observable can be defined as a collection where data arrives over time and thus opening up a channel for continuous asynchronous communication. The concept of observables is based on the classic observer design pattern, one or many observer's can subscribe to the observable and get notified whenever the observable is updated.

Composition with Reactive Operators

The real power of observables comes from the array like operations that can be performed on the observables, operators that allow you to transform, combine, manipulate, and work with the sequences of items emitted by Observables.

The reactive operators allow to compose asynchronous sequences together in a declarative manner with all the efficiency benefits of callbacks but without the drawbacks of nesting callback handlers that are typically associated with asynchronous systems.

Observables in Angular

Angular makes extensive use of observables through RxJs library for various common asynchronous tasks, listed below are few examples:

  • The EventEmitter class extends observable.
  • The HTTP module uses observables to handle AJAX calls.
  • The Router module provides events in the navigation process as observables.
  • Reactive Forms module uses observables to monitor form control values.