ReactiveSetExtensions<E> extension
Extension methods on Set to create reactive sets.
These extensions allow regular Dart sets to be converted into reactive sets that automatically track changes and emit notifications when the set is modified. Sets are particularly useful for collections where each element should be unique.
Example usage:
// Create a reactive set
final activeUsers = {'user1', 'user2', 'admin'}.reactive;
// Listen for changes
activeUsers.stream.listen((snapshot) {
final added = snapshot.newValue.difference(snapshot.oldValue);
final removed = snapshot.oldValue.difference(snapshot.newValue);
print('Added: $added, Removed: $removed');
});
// Modify the set (triggers notification)
activeUsers.value.add('user3');
activeUsers.value = Set.from(activeUsers.value); // Trigger notification
- on
-
- Set<
E>
- Set<
Properties
-
reactive
→ Reactive<
Set< E> > -
Available on Set<
Creates a reactive set from this set.E> , provided by the ReactiveSetExtensions extensionno setter
Methods
-
toReactive(
{List< FluxivityMiddleware< ? middlewares}) → Reactive<Set< >E> >Set< E> > -
Available on Set<
Creates a reactive set with custom middleware from this set.E> , provided by the ReactiveSetExtensions extension