Creates an observable with no observers.
OptionalonFirstSubscribe: (observable: Observable<T>) => void | (() => void)
Called when the observer count goes from 0 to 1. May return a teardown function, called when the observer count goes back to 0.
ProtectedaddAdds observer to the observer list, triggering onFirstSubscribe if it is the first one.
The observer to add.
Synchronously calls every subscribed observer with data.
Value passed to each observer.
ProtectedremoveRemoves observer from the observer list, calling the teardown returned by
onFirstSubscribe if it was the last one.
The observer to remove.
Registers observer to be called on every subsequent Observable.notify.
Function called with each notified value.
A Subscription to stop receiving notifications.
Minimal synchronous publish/subscribe primitive.
Observers are called synchronously, in subscription order, each time Observable.notify is invoked. An optional
onFirstSubscribecallback lets the observable lazily set up its underlying source (e.g. a DOM listener) when the first observer subscribes; the function it returns, if any, is called to tear that source down when the last observer unsubscribes.Example