Manage channel metacounters
Using channel metacounter, you can store additional information to channels such as the tracking number of likes on a message. A channel metacounter is an object that doesn't belong to a Channel
object and can be fetched or rendered into the UI.
A channel metacounter is primarily used to track and update discrete indicators in a channel. Use channel metacounter instead of channel metadata when you need an integer with increasing and decreasing atomic operations.
Create a metacounter
To store a metacounter into a channel, create a dictionary of key-value items where the key is a string and the value is an integer. Then pass the dictionary as an argument to a parameter when calling the createMetaCounters()
method. You can store multiple key-value items in the dictionary.
Update a metacounter
The procedure of updating a channel metacounter is the same as creating a channel metacounter. Values of existing keys are updated and values of new keys are added.
Increase a metacounter
You can increase values in a channel metacounter by passing an object of keys as an argument to a parameter in the increaseMetaCounters()
method. The values of corresponding keys in the metacounter are increased by the specified number.
Decrease a metacounter
You can decrease values in a channel metacounter by passing an object of keys as an argument to a parameter in the decreaseMetaCounters()
method. The values of corresponding keys in the metacounter are decreased by the specified number.
Retrieve a metacounter
You can retrieve channel metacounter by creating a collection of keys to retrieve and passing it as an argument to a parameter in the getMetaCounters()
method. A MetaCounter
object is returned through the callback function with the corresponding key-value items.
Delete a metacounter
You can delete a channel metacounter as shown below.