ObservableReference<T> class
A mutable object holder that allows listening on a stream of changes.
Changes to the value using value=
are added to a broadcast stream. If the
new value is equivalent to the current value, nothing's added to the stream.
- Inheritance
-
- Object
- ChangeNotificationProvider<
T> - ObservableReference
- Mixed-in types
- Implementers
Constructors
-
ObservableReference(T? _value, {EqualsFn<
T?> equalsFn = _defaultEq, bool coalesce = false}) -
Creates a listenable value holder, starting with the given value.
Optionally takes custom equality function.
Changes are published synchronously by default. When
coalesce
is set, the changes in the current execution block are collected, and only the last value will be published (in an async scheduled microtask).
Properties
-
changes
→ Stream<
Change< T?> > -
Provides a stream of change pairs.
no setterinherited
-
firstNonNull
→ Future<
T?> -
Blocks until value is non-null, and then completes with that value.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListener → bool
-
Whether there is a subscriber to stream or changes.
no setterinherited
-
nonNullValues
→ Stream<
T?> -
A Stream of all non-null values on this view, including the current
value at the time the stream is listened to (if it's non-null).
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
T?> -
Provides a stream of object values when the reference changes.
no setterinherited
- value ↔ T?
-
The currently-set value.
getter/setter pairoverride-getter
-
values
→ Stream<
T?> -
A Stream of all values on this view, including the current value at
the time the stream is listened to.
no setterinherited
Methods
-
dispose(
) → void -
Disposes this disposable and any resources it has open.
override
-
listen(
Stream< T> stream) → Future - Listens to the given stream and sets the reference's value to whatever is emitted on the stream.
-
map<
M> (M mapper(T?)) → ObservableView< M> -
Returns a new ObservableView which is created by lazily calling
mapper
on this view's value, stream, and changes properties.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyChange(
[T? previous, T? next]) → void -
Notifies the streams about a new value (or forces the notification without
equality check).
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited