ITUIStore

ITUIStore

Methods

watch(storeName, options) → {void}

UI component registration listener

Example
// UI layer listening for conversation list update notification
let onConversationListUpdated = function(conversationList) {
  console.warn(conversationList);
}
TUIStore.watch(StoreName.CONV, {
  conversationList: onConversationListUpdated,
})
Parameters:
Name Type Description
storeName StoreName

Store name

options IOptions

UI component registration listener information

Returns:
Type
void

unwatch(storeName, options) → {void}

UI component unregister listener callback Note: The callback function passed when unregistering must be the same as the one used for registration

Example
// UI layer unregister conversation list update notification
TUIStore.unwatch(StoreName.CONV, {
  conversationList: onConversationListUpdated,
})
Parameters:
Name Type Description
storeName StoreName

Store name

options IOptions

Listener information, including callbacks to be unregistered

Returns:
Type
void

update(storeName, key, data) → {void}

Update store

  • When using custom store, this API can be used to update custom data
Example
// UI layer update custom Store data
const data: string = 'Custom data'
TUIStore.update(StoreName.CUSTOM, 'customKey', data)
Parameters:
Name Type Description
storeName StoreName

Store name

key String

Key to update

data any

Data to update

Returns:
Type
void

getConversationModel(conversationID) → {IConversationModel}

Get conversationModel

Example
// Get conversationModel
const conversationID = 'C2C9241'
const conversationModel = TUIStore.getConversationModel(conversationID);
Parameters:
Name Type Description
conversationID string

Conversation ID

Returns:
Type
IConversationModel

getMessageModel(messageID) → {MessageModel}

Get messageModel

Example
// Get messageModel
const messageID = '144115225790497300-1686557023-31267600'
const messageModel = TUIStore.getMessageModel(messageID);
Parameters:
Name Type Description
messageID string

Message ID

Returns:
Type
MessageModel