ContextThreads
Provides a wrapper for functions used to manage Threads in given Context.
Constructors
constructor
constructor(_endpoint: Endpoint,_eventDispatcher: EventDispatcher)
Name | Type | Description |
---|---|---|
_endpoint | Endpoint | |
_eventDispatcher | EventDispatcher |
Methods
deleteMessage
Deletes message with matching `messageId`.
async deleteMessage(messageId: string)
Name | Type | Description |
---|---|---|
messageId | string | ID of the message to delete |
Type | Description |
---|---|
Promise<void> | a promise that resolves with void |
getMessage
Returns message with matching `messageId`.
async getMessage(messageId: string)
Name | Type | Description |
---|---|---|
messageId | string | ID of the message to get |
Type | Description |
---|---|
Promise<Message> | `Promise<Message> |
list
Returns a list of Threads in given Context.
async list(query: {
contextId: string;
options: ListOptions;
pageIndex: number;
})
Name | Type | Description |
---|---|---|
query.contextId | string | indicates from which Context should Threads be fetched |
query.options | ListOptions | optional `options` object |
query.pageIndex | number | indicates from which page the list should start |
Type | Description |
---|---|
Promise<PagingList<Thread>> | - promise of |
new
Creates a new Thread inside Context.
async new(newThread: {
contextId: string;
managers: UserWithPubKey[];
privateMeta: Uint8Array;
publicMeta: Uint8Array;
users: UserWithPubKey[];
})
Name | Type | Description |
---|---|---|
newThread.contextId | string | |
newThread.managers | UserWithPubKey[] | list of `UserWithPubKey` objects which indicates who will have access (and management rights) to the updated Thread |
newThread.privateMeta | Uint8Array | private metadata of the Thread |
newThread.publicMeta | Uint8Array | public metadata of the Thread |
newThread.users | UserWithPubKey[] | list of `UserWithPubKey` objects which indicates who will have access to the updated Thread |
Type | Description |
---|---|
Promise<string> | - ID of created Thread |
on
Registers an event listener for Thread-related events.
on(eventType: T, callback: (payload: Extract<ThreadCreatedEvent, {type: T;}> | Extract<ThreadUpdatedEvent, {type: T;}> | Extract<ThreadDeletedEvent, {type: T;}> | Extract<ThreadStatsEvent, {type: T;}>)=>void)
Name | Type | Description |
---|---|---|
eventType | T | type of event to listen for |
callback | (payload: Extract<ThreadCreatedEvent, {type: T;}> | Extract<ThreadUpdatedEvent, {type: T;}> | Extract<ThreadDeletedEvent, {type: T;}> | Extract<ThreadStatsEvent, {type: T;}>)=>void | callback function to execute when the event occurs |
Type | Description |
---|---|
SubscribeForChannel<"thread"> & {
removeEventListener: ()=>void;
} | object containing the |
subscribeToThreadEvents
Subscribes to events related to Threads: - `threadCreated` - `threadDeleted` - `threadStatsChanged` - `threadUpdated`
async subscribeToThreadEvents()
Type | Description |
---|---|
Promise<SubscribeForChannel<"thread">> | `SubscribeForChannel<'thread'> |
unsubscribeFromThreadEvents
Unsubscribes from events related to given Thread.
async unsubscribeFromThreadEvents()
Type | Description |
---|---|
Promise<void> | a promise that resolves with void |