Observables - YamamotoDesu/Yamamoto-Notes GitHub Wiki

Observables

Observable provides the foundation of Rx code: the ability to asynchronously produce a sequence of events that can “carry” an immutable snapshot of generic data of type Element.
In the simplest words, it allows consumers to subscribe for events, or values, emitted by another object over time.

The Observable class allows one or more observers to react to any events in real time and update the app’s UI, or otherwise process and utilize new and incoming data.

The ObservableType protocol (to which Observable conforms) is extremely simple.

An Observable can emit (and observers can receive) only three types of events:

1. Next Event

An event that “carries” the latest (or “next”) data value. This is the way observers “receive” values. An Observable may emit an indefinite amount of these values, until a terminating event is emitted.

2. Completed Event

This event terminates the event sequence with success. It means the Observable completed its lifecycle successfully and won’t emit additional events.

3. Error Event

The Observable terminates with an error and will not emit additional events.

⚠️ **GitHub.com Fallback** ⚠️