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
observerprovided will have itsonAdded,onRemoved, and/oronUpdatedcalled.observer.onAddedwill be called when an item is added to the collectionobserver.onRemovedwill be called when an item is removed from the collectionobserver.onUpdatedwill be called when an item has some of its properties changedobserver.onCollectionUpdatedwill be called after some set of the above events have occured (item added/removed/updated)
When first subscribing, the observers'
onAddedwill be called for each item in the collection. The same is true foronCollectionUpdatedwhich provides the latest view of the entire collectiononCollectionUpdatedandonAddedcontinue 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
conditionprovided will be called. When theconditionreturns 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
conditionreturns 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.