What Is An Observable?

Observables emit data as a stream of values, observers are functions which subscribe(i.e consume) this data and do some processing on this received data.

Observerable ---->Operator------> Observer. 

Observable emits data as a stream of values, observers are functions which subscribe (i.e consume) this data and do some processing on this received data.

Observers subscribe to an observable. Observable is an asynchronous data stream.

The observer is a data sink.

What is a data sink?

Data sink, in this context, is a function designed to receive incoming events or data from another object or function.

In an asynchronous data stream, we can't tell when the next value in a stream of values will be emitted or generated. Observable is a (data)source of a synchronous/asynchronous stream.

Observable is a continuous data emitter, the data may be emitted at varying intervals of time. The first piece of data comes at 9:30 AM, the next data comes at 9:45 AM, the third piece comes at 3:00 PM, the next one at 3:03 PM .....so on and so forth. An example is a Stock Price Ticker or RSS Feed, Twitter Feeds, etc.

An observer must have the following three functions implemented,

observer.next() , observer.error(), observer.complete()

Observers can unsubscribe or opt out of the data stream emitted by the observable.

observable.subscribe(observer), observer.unsubscribe(observer)

Observable can emit data synchronously (emitting the next value at fixed intervals) or asynchronously (at random intervals).

What are operators?

Operators sit between an observable and observer function.They shape or change the data emitted by an observable and pass on the data to the observer. Ex: MAP, REDUCE, FILTER

We also can have an observable passing its data into several layers of observers i.e

observable----(data stream)--->Operator------>(modified data stream)--->Observer1-----(modified data stream)---->observer2--------(modified data stream)---->observer3 etc....

We can also have multiple observer functions subscribing to a single observable.......think something similar to multicast delegates.

Think delegates.....

The observer takes values from the observable and does something with it; i.e., it listens to the data.

Observable calls the next(), error(), Complete() functions on the observer that has subscribed to it to pass/push the next value it emits, to publish an error and to signal the end of the data stream emitted from it respectively.