SignalResult<T> class

A reactive wrapper around Result<T, AppFailure> backed by a Signal.

SignalResult is the v6 replacement for raw Stream<Result<T, AppFailure>> in ZuraffaUseCase return types. It provides:

  • O(1) reads: value is a direct signal read, no stream overhead.
  • Zero-allocation snapshots: previous result is cached until changed.
  • Fine-grained subscriptions: listen to result changes without buffering.
  • Async-to-sync bridge: await the next emission via nextValue.

Lifecycle

SignalResult owns its internal Signal. When disposed, the signal is disposed and all listeners are released.

Constructors

SignalResult.failure(AppFailure error)
Create a SignalResult from an initial failure.
factory
SignalResult.initial(Result<T, AppFailure> result)
Create a SignalResult from an initial Result.
factory
SignalResult.success(T value)
Create a SignalResult from an initial success value.
factory

Properties

data → T?
Current data if Success, otherwise null.
no setter
error → AppFailure?
Current error if Failure, otherwise null.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isDisposed → bool
no setter
isFailure → bool
Whether the current state is a failure.
no setter
isLoading → bool
Whether the current state is actively loading (not idle).
no setter
isSuccess → bool
Whether the current state is a success.
no setter
nextValue → Future<Result<T, AppFailure>>
Listen only to the next non-loading result (success or failure).
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → Result<T, AppFailure>
Current result value. O(1) — direct signal read.
no setter

Methods

dispose() → void
Dispose this SignalResult and release all listeners.
emit(Result<T, AppFailure> result) → void
Publish a new Result. Notifies listeners only if the result changes.
emitFailure(AppFailure error) → void
Publish a failure.
emitLoading() → void
Publish a loading state.
emitSuccess(T value) → void
Publish a success value.
flatMap<R>(SignalResult<R> transform(T value)) → SignalResult<R>
Flat-map: chain another async operation on success. The previous inner subscription is cancelled before binding a new one.
listen(void callback(Result<T, AppFailure> result)) → SignalSubscription
Listen to result changes. Callback receives the new result immediately.
map<R>(R transform(T value)) → SignalResult<R>
Transform the success value, preserving failure/loading states.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void callback(AppFailure error)) → SignalSubscription
Listen only to failures.
onSuccess(void callback(T value)) → SignalSubscription
Listen only to success values.
toString() → String
A string representation of this object.
inherited
update(Result<T, AppFailure> updater(Result<T, AppFailure> current)) → void
Functional update over the current result.
updateData(T updater(T currentData)) → void
Update only the success data, preserving failure/loading states.

Operators

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

Static Methods

fromFuture<T>(Future<T> future, {bool emitLoading = true}) → SignalResult<T>
Create a SignalResult from a Future.