MapSignal<K, V> class
Signal for Map with convenient mutation methods.
MapSignal provides reactive map operations while maintaining immutability. Each mutation creates a new map instance to trigger updates.
Basic Usage
final settings = MapSignal<String, dynamic>({'theme': 'light'});
// Add/Update entry
settings.put('theme', 'dark');
// Remove entry
settings.remove('theme');
// Clear all
settings.clear();
Binding to UI
Slot(
connect: settings,
to: (context, map) {
return Text('Theme: ${map['theme']}');
},
)
- Inheritance
-
- Object
- NeuronAtom<
Map< K, V> > - Signal<
Map< K, V> > - MapSignal
Constructors
Properties
- debugLabel → String?
-
Debug label for identification in DevTools.
finalinherited
-
entries
→ Iterable<
MapEntry< K, V> > -
Get all entries.
no setter
-
equals
→ bool Function(Map<
K, V> a, Map<K, V> b)? -
Custom equality function to determine if value has changed.
finalinherited
-
guard
→ Map<
K, V> Function(Map<K, V> current, Map<K, V> next)? -
Value guard/transformer called before setting a new value.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether this atom has any listeners.
no setterinherited
-
initialValue
→ Map<
K, V> -
The initial value of the atom.
no setterinherited
- isDisposed → bool
-
Whether this atom has been disposed.
no setterinherited
- isEmpty → bool
-
Check if map is empty.
no setter
- isNotEmpty → bool
-
Check if map is not empty.
no setter
-
keys
→ Iterable<
K> -
Get all keys.
no setter
- length → int
-
Get length of map.
no setter
- onCancel → VoidCallback?
-
Callback invoked when the last listener unsubscribes.
finalinherited
- onListen → VoidCallback?
-
Callback invoked when the first listener subscribes.
finalinherited
-
previousValue
→ Map<
K, V> ? -
The previous value of the atom (before the last change).
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
Map< K, V> > -
A broadcast stream of value changes.
no setterinherited
-
val
→ Map<
K, V> -
Short alias for the current value.
no setterinherited
-
value
↔ Map<
K, V> -
Override value getter to support dependency tracking for Computed.
getter/setter pairinherited
-
values
→ Iterable<
V> -
Get all values.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Adds a listener to be called when the value changes.
inherited
-
clear(
) → void - Clear all entries.
-
containsKey(
K key) → bool - Check if key exists.
-
dispose(
) → void -
Disposes the atom, removing all listeners.
inherited
-
emit(
Map< K, V> val) → void -
Assigns a new value and notifies listeners if the value changed.
inherited
-
mutate(
void mutator(Map< K, V> map)) → void - Mutate the map in-place and notify listeners.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Manually notifies all listeners.
inherited
-
onActive(
) → void -
Called when the first listener is added.
inherited
-
onInactive(
) → void -
Called when the last listener is removed.
inherited
-
put(
K key, V value) → void - Put a key-value pair.
-
putAll(
Map< K, V> entries) → void - Put multiple entries.
-
remove(
K key) → V? - Remove a key.
-
removeListener(
VoidCallback listener) → void -
Removes a previously added listener.
inherited
-
reset(
) → void -
Resets the atom to its initial value.
inherited
-
select<
R> (R selector(Map< K, V> value)) → NeuronAtom<R> -
Creates a new atom that selects a part of this atom's value.
inherited
-
subscribe(
VoidCallback listener) → VoidCallback -
Adds a listener and returns a callback that cancels the subscription when called.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
K key, V updater(V? value)) → void - Update value for key using function.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
K key) → V? - Get value by key.