RxSet<T> class
A reactive implementation of Set backed by RxState.
This class provides reactive tracking for set operations:
- Element presence tracking (
contains) - Size tracking (
length) - Mutations (
add,remove)
All mutations follow an immutable update pattern: a new Set instance is created before updating the state.
Example:
final set = RxSet<int>({1, 2, 3});
set.add(4); // triggers reactive update
set.contains(1); // tracked read
Key characteristics:
- Reactive read tracking via RxStack
- Immutable updates (Set.copy on mutation)
- Fine-grained dependency tracking support
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → dynamic
-
Unique identifier for debugging or tracking updates in listenWithId.
finalinherited
- isEmpty → bool
-
Whether the set is empty.
no setter
- isNotEmpty → bool
-
Whether the set is not empty.
no setter
- length → int
-
The number of elements in the set.
no setter
- name → String?
-
A human-readable name, mainly used for logging and debugging output.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
set
→ UnmodifiableSetView<
T> -
Returns an unmodifiable view of the underlying set.
no setter
-
value
↔ Set<
T> -
Gets the current value and automatically triggers dependency tracking in RxStack.
getter/setter pairinherited
Methods
-
add(
T item) → bool -
Adds
itemto the set. -
addFieldListener(
dynamic field, void listener(dynamic)) → void -
Adds a field-level listener.
inherited
-
addListener(
void listener(dynamic)) → void -
Adds a global listener.
inherited
-
addListenerWithId(
void listener(dynamic)) → void -
Adds a listener that also receives the state id.
inherited
-
bind(
void onUpdate(Set< T> value)) → void Function() -
Binds a listener to the state.
inherited
-
contains(
T item) → bool -
Checks whether
itemexists in the set. -
deepEquals(
dynamic a, dynamic b) → bool -
inherited
-
dispose(
) → void -
Disposes the state and clears all listeners.
inherited
-
getItem(
dynamic field) → dynamic -
Gets a specific field or index from a collection.
inherited
-
internalUpdate(
Set< T> newValue) → void -
Internal update used by computed or framework-level mechanisms.
It updates the value and triggers global listeners if the value changes.
inherited
-
listen(
void onData(Set< T> value)) → void Function() -
Listens to value changes and immediately emits the current value.
inherited
-
listenByKey(
dynamic key, void onData(dynamic)) → void Function() -
Listens to a specific key in a Map or index in a List.
inherited
-
listenWhere(
bool test(dynamic item), void onData(dynamic)) → void Function() -
Conditional listener.
inherited
-
listenWithId(
void onData(Set< T> value, dynamic id)) → void Function() -
Listens to value changes and provides both value and state id.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyField(
dynamic field) → void -
Notifies all listeners registered for a specific field.
inherited
-
refresh(
) → void -
Manually triggers a refresh.
inherited
-
remove(
T item) → bool -
Removes
itemfrom the set. -
removeFieldListener(
dynamic field, void listener(dynamic)) → void -
Removes a field-level listener.
inherited
-
removeListener(
void listener(dynamic)) → void -
Removes a global listener.
inherited
-
runAsync(
{required Future< Set< asyncAction(), void onLoading(bool loading)?, void onError(Object error)?, int retryCount = 3, Duration retryDelay = const Duration(seconds: 2)}) → Future<T> >void> -
Executes an asynchronous action with automatic retry support.
inherited
-
runAsyncWithStatus(
{required Future< Set< asyncAction(), void onLoading(bool loading)?, void onError(Object error)?}) → Future<T> >void> -
Executes an asynchronous action and updates the state.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
dynamic newValue) → void -
Updates the entire state or attempts a type-conversion update.
inherited
-
updateField<
K extends Object> (K field, Object? newValue) → void -
Updates a specific key in a Map or an index in a List.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited