ControlObservable<T> class

The primary concrete implementation of an observable value.

This class manages a value, a list of subscribers, and handles the logic for notifying subscribers when the value changes. It also provides factory constructors to easily create observables from other reactive sources like Streams and Futures.

Inheritance
Implementers
Available extensions

Constructors

ControlObservable(T _value)
Observable that handles listeners and value changes. Initial value of this object. This object must call dispose to release resources.

Properties

hashCode int
The hash code for this object.
no setterinherited
internalData ↔ dynamic
Optional data that can be attached to the observable, often for internal use by components or for tracking purposes.
getter/setter pairinherited
isActive bool
Checks availability of this observable. Inactive observers should not be notified.
no setteroverride
isEmpty bool
Checks if value is not set.
no setterinherited
isFalse bool

Available on ObservableModel<bool>, provided by the ObservableBoolExt extension

Checks if the observable's current value is false or null.
no setter
isNotEmpty bool
Checks if value is set.
no setterinherited
isTrue bool

Available on ObservableModel<bool>, provided by the ObservableBoolExt extension

Checks if the observable's current value is true.
no setter
isValid bool
Checks validity of this observable. Invalid observers should not be notified.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
subCount int
Number of active listeners.
no setter
subs List<ControlSubscription<T>>
Active subscriptions of this observable. This is exposed just for debug and test purposes. DO NOT modify this list externally!
final
value ↔ T
The current value held by the observable.
getter/setter pairinherited-setteroverride-getter

Methods

cancel(ControlSubscription<T> subscription) → void
Cancels a subscription, preventing it from receiving further notifications.
override
cast<U>() ObservableValue<U>

Available on ObservableValue, provided by the ObservableValuExt extension

Cast this observable.
clear() → void
Invalidates and clears all subs.
createSubscription([dynamic args]) ControlSubscription<T>
dispose() → void
Releases resources used by the object.
override
disposeWith(DisposeObserver observer) → void

Available on Disposable, provided by the DisposableExt extension

Register for dispose with given observer.
listen(VoidCallback action) ControlSubscription<T>
Subscribes to the observable to be notified of changes.
inherited
merge(Object other) ObservableGroup

Available on ObservableBase, provided by the ObservableBaseExt extension

Creates new group, that listens to both observables.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Notify this object to propagate changes.
override
pause() → void
When observable is paused, then notify breaks all callbacks.
resume() bool
Resume notify to listeners. Only isValid observable can be resumed.
setFalse() → void

Available on ObservableModel<bool>, provided by the ObservableBoolExt extension

Sets the observable's value to false and notifies listeners.
setTrue() → void

Available on ObservableModel<bool>, provided by the ObservableBoolExt extension

Sets the observable's value to true and notifies listeners.
setValue(T value, {bool notify = true, bool forceNotify = false}) → void
Sets the observable's value.
override
subscribe(ValueCallback<T> action, {bool current = false, dynamic args}) ControlSubscription<T>
Subscribes to changes in the observable's value.
override
toggle() bool

Available on ObservableModel<bool>, provided by the ObservableBoolExt extension

Toggles the boolean value (true to false, or false/null to true) and notifies listeners.
toString() String
A string representation of this object.
inherited
wrap<U>(ObservableValue<U> other, {T converter(U value)?, bool autoDispose = true}) ControlSubscription<U>

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

empty<T>([T? value]) ControlObservable<T?>
Creates an observable that can hold a nullable value.
handle<T>(ObservableModel<T?> observable) ObservableValue<T?>
Wraps an existing observable to hide its concrete implementation, exposing only the ObservableValue interface.
of<T>(Object? object) ObservableValue<T?>
A powerful factory that creates an ObservableValue from various sources.
ofChannel<T>(ObservableBase channel) ControlObservable<T?>
Creates an observable from given channel. This object wraps channel and propagates their notifies.
ofFuture<T>(Future<T> future) ControlObservable<T?>
Creates an observable from given future. Future value is propagated to this observable. This object waits to future completion and then sets value. If error occurs nothing happens.
ofListenable<T>(Listenable listenable) ControlObservable<T?>
Creates an observable from given listenable. Listenable value, if any, is propagated to this observable. This object listen to listenable and notifies about value changes (if ValueListenable is given).
ofStream<T>(Stream<T> stream) ControlObservable<T?>
Creates an observable from given stream. Stream value is propagated to this observable. This object listen to stream and notifies about value changes.