SignalSlice<T> class

A fine-grained reactive slice that wraps a SignalResult<T>.

SignalSlice is the v6 replacement for monolithic .state.dart objects. Each UseCase gets its own slice, so UI rebuilds are O(1) and isolated.

final productSlice = SignalSlice<Product>(
  useCase: getProductUseCase,
  params: GetProductParams(id: '123'),
);

// Subscribe to ONLY this slice
productSlice.listen((product) => setState(() => _product = product));
Available extensions

Constructors

SignalSlice({required ZuraffaUseCase<dynamic, T> useCase, required dynamic params, ZuraffaContext? context})

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 slice has failed.
no setter
isLoading → bool
Whether the slice is in loading state.
no setter
isSuccess → bool
Whether the slice has succeeded.
no setter
result → SignalResult<T>
The underlying SignalResult. Lazily created on first access.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

bindCache() → SignalSubscription

Available on SignalSlice<T>, provided by the CacheBinding extension

Subscribe this slice to cache updates for type T.
dispose() → void
listen(void callback(T? data, AppFailure? error)) → SignalSubscription
Subscribe to changes on this slice only. Other slices are unaffected.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onFailure(void callback(AppFailure error)) → SignalSubscription
Subscribe only to failures.
onSuccess(void callback(T data)) → SignalSubscription
Subscribe only to success values.
refresh([dynamic newParams]) → void
Re-execute the underlying use case with new params.
toString() → String
A string representation of this object.
override
trackCacheSubscription(SignalSubscription sub) → void
Registers a subscription to be cancelled when this slice is disposed.

Operators

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