RxEvent<T> class
A fire-and-forget signal: navigation, toasts, "the link was invalid".
Unlike Rx, every emit notifies listeners, even when the emitted value equals the previous one — an event that happens twice is two events.
Consume it from the widget tree with EventListener:
// state
final invalidLink = RxEvent<Object>();
// controller
state.invalidLink.emit(error);
// page
EventListener<Object>(
event: state.invalidLink,
listener: (context, _) => Navigator.of(context).pop(),
child: const MyPage(),
)
Most screens don't need this: when the controller can drive the side effect
itself, a routing callback is simpler and keeps the page free of logic.
- Inheritance
-
- Object
- ChangeNotifier
- RxEvent
- Implemented types
-
- ValueListenable<
T?>
- ValueListenable<
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T?
-
The most recently emitted value, or
nullbefore the first emit.no setteroverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
emit(
T newValue) → void -
Notifies listeners with
newValue, unconditionally. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
Always throws — see Rx.toString.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited