ControlObservable<T> class

Observable class that handles listeners and value changes.

Inheritance
Implementers
Available extensions

Constructors

ControlObservable.new(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
Serves for internal data or marker. Exposed to public API due to usage as custom 'client' data.
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 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 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
Current value of this observable.
getter/setter pairinherited-setteroverride-getter

Methods

cancel(ControlSubscription<T> subscription) → void
Cancels given subscription.
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
Used to clear and dispose object. Unsubscribe and close all sources. Prepare object for GC. Can be called multiple times!
override
disposeWith(DisposeObserver observer) → void

Available on Disposable, provided by the DisposableExt extension

Register for dispose with given observer.
listen(VoidCallback action) ControlSubscription<T>
Subscribe to listen future changes. Returns ControlSubscription for later connection close.
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 value to 'false'. Listeners are notified if value is changed.
setTrue() → void

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

Sets value to 'true'. Listeners are notified if value is changed.
setValue(T value, {bool notify = true, bool forceNotify = false}) → void
Robust value setter. notify when set is called when value is different. Disable notify to prevent propagation of this value change. This can be handy when we change value multiple times during one function call and we want to notify just last change. Enable forceNotify to notify listeners even if value is not changed.
override
subscribe(ValueCallback<T> action, {bool current = true, dynamic args}) ControlSubscription<T>
override
toggle() bool

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

Toggles current value and notifies listeners. 'true' -> 'false' 'false' -> 'true'
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

empty<T>([T? value]) ControlObservable<T?>
Returns null version of observable.
handle<T>(ObservableModel<T?> observable) ObservableValue<T?>
Wraps given observable. Can be handy to 'hide' concrete functionality.
of<T>(Object? object) ObservableValue<T?>
Creates an observable from given object. This method is able to consume:
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.