ITUIStore

ITUIStore

Methods

watch(storeName, options) → {void}

UI 组件注册监听

Example
// UI 层监听会话列表更新通知
let onConversationListUpdated = function(conversationList) {
  console.warn(conversationList);
}
TUIStore.watch(StoreName.CONV, {
  conversationList: onConversationListUpdated,
})
Parameters:
Name Type Description
storeName StoreName

store 名称

options IOptions

UI 组件注册的监听信息

Returns:
Type
void

unwatch(storeName, options) → {void}

UI 组件取消监听回调 注意:取消监听时传入的回调函数和注册监听的回调函数是同一个

Example
// UI 层取消监听会话列表更新通知
TUIStore.unwatch(StoreName.CONV, {
  conversationList: onConversationListUpdated,
})
Parameters:
Name Type Description
storeName StoreName

store 名称

options IOptions

监听信息,包含需要取消的回调等

Returns:
Type
void

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

更新 store

  • 使用自定义 store 时,可以用此 API 更新自定义数据
Example
// UI 层更新自定义 Store 数据
const data: string = '自定义数据'
TUIStore.update(StoreName.CUSTOM, 'customKey', data)
Parameters:
Name Type Description
storeName StoreName

store 名称

key String

需要更新的 key

data any

待更新的数据

Returns:
Type
void

getConversationModel(conversationID) → {IConversationModel}

获取 conversationModel

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

会话 ID

Returns:
Type
IConversationModel

getMessageModel(messageID) → {MessageModel}

获取 messageModel

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

消息 ID

Returns:
Type
MessageModel