CallbackObserver<T> class

A simple Observer implementation using callbacks.

Use this when you don't want to create a custom Observer class.

Example:

final observer = CallbackObserver<User>(
  onDataCallback: (user) => print('Got user: ${user.name}'),
  onErrorCallback: (failure) => print('Error: $failure'),
  onDoneCallback: () => print('Done'),
);
Inheritance

Constructors

CallbackObserver({required void onDataCallback(T data), void onErrorCallback(AppFailure failure)?, void onDoneCallback()?})
Create a CallbackObserver with the given callbacks.

Properties

hashCode → int
The hash code for this object.
no setterinherited
onDataCallback → void Function(T data)
Callback for data events
final
onDoneCallback → void Function()?
Callback for done events
final
onErrorCallback → void Function(AppFailure failure)?
Callback for error events
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onData(T data) → void
Called when a new value is emitted.
override
onDone() → void
Called when the stream completes.
override
onError(AppFailure failure) → void
Called when an error occurs.
override
toString() → String
A string representation of this object.
inherited

Operators

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