Type parameters
-
ItemT
The type of the items in the map being observed.
Hierarchy
- IObservableMap
Index
Methods
subscribe
-
Subscribe to changes in this map.
When this observable detects a change, the
observer
provided will have itsonAdded
,onRemoved
, and/oronUpdated
called.observer.onAdded
will be called when an item is added to the collectionobserver.onRemoved
will be called when an item is removed from the collectionobserver.onUpdated
will be called when an item has some of its properties changedobserver.onCollectionUpdated
will be called after some set of the above events have occured (item added/removed/updated)
When first subscribing, the observers'
onAdded
will be called for each item in the collection. The same is true foronCollectionUpdated
which provides the latest view of the entire collectiononCollectionUpdated
andonAdded
continue to fire as changes to the collection occur.const subscription = sdk.Tag.data.subscribe({ onAdded: (index, item, collection) => { console.log(`Tag added at index ${index}:`, item); }, onRemoved: (index, item, collection) => { console.log(`Tag removed from index ${index}:`, item); }, onUpdated: (index, item, collection) => { console.log(`Tag updated at index ${index}:`, item); }, onCollectionUpdated: (collection) => { console.log('Current collection of tags:', collection); } });
Parameters
-
observer: IMapObserver<ItemT>
Returns ISubscription
A subscription that can be used to remove the subscribed observer.
waitUntil
-
Wait for a specific condition on this map to be met. When this observable detects a change, the
condition
provided will be called. When thecondition
returns true, the returned Promise will be resolved.// Get the tag collection to use in your application const tags: MpSdk.Dictionary<MpSdk.Tag.TagData> = await props.sdk.Tag.data.waitUntil( () => true );
Parameters
-
condition: ICondition<Dictionary<ItemT>> | ConditionCallback<Dictionary<ItemT>>
Returns Promise<Dictionary<ItemT>>
A promise that is resolved when
condition
returns true. -
A map that can have its changes observed via subscribing an IMapObserver or that can be waited on for a specific condition to be met.