Child observable should call this method on this lazy observable when it was started.
Child observable should call this method on this lazy observable when it was started. This lazy observable calls onStart if this action has given it its first observer (internal or external). See docs for Observable.onStart
And an external observer
And an external observer
Note: Observer can be added more than once to an Observable.
Note: Observer can be added more than once to an Observable. If so, it will observe each event as many times as it was added.
Note: This is enforced to be a Set outside of the type system #performance
Note: This is enforced to be a Set outside of the type system #performance
Basic idea: Lazy Observable only holds references to those children that have any observers (either directly on themselves, or on any of their descendants).
Basic idea: Lazy Observable only holds references to those children that have any observers (either directly on themselves, or on any of their descendants). What this achieves: - Stream only propagates its value to children that (directly or not) have observers - Stream calculates its value only once regardless of how many observers / children it has) (so, all streams are "hot" observables) - Stream doesn't hold references to Streams that no one observes, allowing those Streams to be garbage collected if they are otherwise unreachable (which they should become when their subscriptions are killed by their owners)
This method is fired when this observable starts working (listening for parent events and/or firing its own events)
This method is fired when this observable starts working (listening for parent events and/or firing its own events)
The above semantic is universal, but different observables fit onStart differently in their lifecycle: - State is an eager observable, it calls onStart on initialization. - LazyObservable (Stream or Signal) calls onStart when it gets its first observer (internal or external)
So, a State observable calls onStart only once in its existence, whereas a LazyObservable calls it potentially multiple times, the second time being after it has stopped (see onStop).
This method is fired when this observable stops working (listening for parent events and/or firing its own events)
This method is fired when this observable stops working (listening for parent events and/or firing its own events)
The above semantic is universal, but different observables fit onStop differently in their lifecycle: - State is an eager, Owned observable. It calls onStop when its Owner decides to State.kill it - LazyObservable (Stream or Signal) calls onStop when it loses its last observer (internal or external)
So, a State observable calls onStop only once in its existence. After that, the observable is disabled and will never start working again. On the other hand, a LazyObservable calls onStop potentially multiple times, the second time being after it has started again (see onStart).
Parent observers are not immediately active.
Parent observers are not immediately active. onStart/onStop regulates that.
whether observer was removed (false
if it wasn't subscribed to this observable)
Child observable should call this method on this lazy observable when it was stopped.
Child observable should call this method on this lazy observable when it was stopped. This lazy observable calls onStop if this action has removed its last observer (internal or external). See also docs for Observable.onStop
Schedule an external observer to be removed in the next transaction.
Schedule an external observer to be removed in the next transaction. This will still happen synchronously, but will not interfere with iteration over the observables' lists of observers during the current transaction.
Note: To completely disconnect an Observer from this Observable, you need to remove it as many times as you added it to this Observable.
Get a lazy observable that emits the same values as this one (assuming it has observers, as usual)
Get a lazy observable that emits the same values as this one (assuming it has observers, as usual)
This is useful when you want to map over an Observable of an unknown type.
Note: Observable itself has no "map" method because mapping over State without expecting / accounting for State's eagerness can result in memory leaks. See README.
Stream that combines the latest values from two streams into a tuple. Only fires after both streams have sent a value.
Note: this stream forgets any previous values of parent streams once it's stopped