ResourceSelector<Input, Output> class

The selector function allows filtering the Resource's data by reading only the properties that you care about.

The advantage is that you keep handling the loading and error states.

Inheritance

Constructors

ResourceSelector({required Resource<Input> resource, required Output selector(Input), required String name})
The selector function allows filtering the Resource's data by reading only the properties that you care about.

Properties

disposed bool
getter/setter pairinherited
fetcher → (Future<Output> Function()?)
The asynchrounous function used to retrieve data.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
hasObservers bool
no setterinherited
hasPreviousValue bool
Indicates if there is a previous value. It is especially helpful if T is nullable.
no setterinherited
listenerCount int
Returns the number of listeners listening to this signal.
no setterinherited
name String
finalinherited
options SignalOptions<ResourceState<Output>>
Options used to customize the behaviour of a signal
finalinherited
previousState ResourceState<Output>?
The previous resource state
no setterinherited
previousValue ResourceState<Output>?
The previous value, if any.
no setterinherited
resource Resource<Input>
The input resource
final
resourceOptions ResourceOptions
The resource options
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selector → Output Function(Input)
The data selector
final
source SignalBase?
Reactive signal values passed to the fetcher, optional.
finalinherited
state ResourceState<Output>
The current resource state
getter/setter pairinherited
stream → (Stream<Output>? Function()?)
The stream used to retrieve data.
finalinherited
value ResourceState<Output>
The current signal value
getter/setter pairinherited

Methods

call() ResourceState<Output>
The current signal value
inherited
dispose() → void
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
observe(ObserveCallback<ResourceState<Output>> listener, {bool fireImmediately = false}) DisposeObservation
Observe the signal and trigger the listener every time the value changes
inherited
onDispose(VoidCallback cb) → void
Fired when the signal is disposing
inherited
refresh() Future<void>
Forces a refresh of the fetcher or the stream.
override
select<Selected>(Selected selector(Output data), {String? name}) Resource<Selected>
The select function allows filtering the Resource's data by reading only the properties that you care about.
inherited
set(ResourceState<Output> newValue) → void
Sets the current signal value with newValue.
inherited
toReadSignal() ReadSignal<ResourceState<Output>>
Converts this Signal into a ReadSignal Use this method to remove the visility to the value setter.
inherited
toString() String
A string representation of this object.
inherited
until(bool condition(ResourceState<Output> value)) FutureOr<ResourceState<Output>>
Returns the future that completes when the condition evalutes to true. If the condition is already true, it completes immediately.
inherited
untilReady() FutureOr<Output>
Returns a future that completes with the value when the Resource is ready If the resource is already ready, it completes immediately.
inherited
update(ResourceState<Output> callback(ResourceState<Output> state)) ResourceState<Output>
Calls a function with the current state and assigns the result as the new state
inherited
updateValue(ResourceState<Output> callback(ResourceState<Output> state)) ResourceState<Output>
Calls a function with the current value and assigns the result as the new value.
inherited

Operators

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