You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceIReactiveMapOptions<K,V>{// Initial entriesentries?: Iterable<[K,V]>;// Extract key from value (for array operations)keyExtractor?: (value: V)=>K;// Emit '{key}.changed' events (default: true)emitKeyEvents?: boolean;}
Methods
CRUD Operations
Method
Description
get(key)
Get value by key
set(key, value)
Set value at key
has(key)
Check if key exists
delete(key)
Delete by key
clear()
Remove all entries
Iteration
Method
Description
keys()
Iterator over keys
values()
Iterator over values
entries()
Iterator over [key, value] pairs
forEach(callback)
Execute callback for each entry
Batch Operations
// Set multiple items at onceusers.setItems([{id: 'u1',name: 'User 1'},{id: 'u2',name: 'User 2'},],true);// true = clear existing first
Utility Methods
// Find first matchingconstadmin=users.find(user=>user.role==='admin');// Filter matchingconstactiveUsers=users.filter(user=>user.active);// Map to new arrayconstnames=users.map(user=>user.name);// Convert to array/mapconstarray=users.toArray();constmap=users.toMap();// Save current state as baselineusers.saveChanges();// Revert to last saved stateusers.revert();
Events
Event
Data
Description
set
{ key, value, previous, isNew }
Entry was set
delete
{ key, value }
Entry was deleted
clear
{ previousSize, previousEntries }
Map was cleared
change
-
Any modification occurred
{key}.changed
{ value, previous }
Specific key changed
items.changed
{ items }
Bulk operation completed
IReactiveValue Interface
ReactiveMap implements IReactiveValue, making it compatible with ReactiveModel properties:
// Use as a property in ReactiveModelclassStoreextendsReactiveModel<Store>{constructor(){super({properties: [{name: 'users',value: ReactiveMap,},],});}}