Skip to main content
reference

ContextThreads

Provides a wrapper for functions used to manage Threads in given Context.

Constructors

constructor

constructor(_endpoint: Endpoint,_eventDispatcher: EventDispatcher)

NameTypeDescription
_endpointEndpoint
_eventDispatcherEventDispatcher

Methods

deleteMessage

Deletes message with matching `messageId`.

async deleteMessage(messageId: string)

NameTypeDescription
messageIdstringID of the message to delete

TypeDescription
Promise<void> a promise that resolves with void

getMessage

Returns message with matching `messageId`.

async getMessage(messageId: string)

NameTypeDescription
messageIdstringID of the message to get

TypeDescription
Promise<Message> `Promise<Message>

list

Returns a list of Threads in given Context.

async list(query: {
contextId: string;
options: ListOptions;
pageIndex: number;
})

NameTypeDescription
query.contextIdstringindicates from which Context should Threads be fetched
query.optionsListOptionsoptional `options` object
query.pageIndexnumberindicates from which page the list should start

TypeDescription
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[];
})

NameTypeDescription
newThread.contextIdstring
newThread.managersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access (and management rights) to the updated Thread
newThread.privateMetaUint8Arrayprivate metadata of the Thread
newThread.publicMetaUint8Arraypublic metadata of the Thread
newThread.usersUserWithPubKey[]list of `UserWithPubKey` objects which indicates who will have access to the updated Thread

TypeDescription
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)

NameTypeDescription
eventTypeTtype of event to listen for
callback(payload: Extract<ThreadCreatedEvent, {type: T;}> | Extract<ThreadUpdatedEvent, {type: T;}> | Extract<ThreadDeletedEvent, {type: T;}> | Extract<ThreadStatsEvent, {type: T;}>)=>voidcallback function to execute when the event occurs

TypeDescription
SubscribeForChannel<"thread"> & { removeEventListener: ()=>void; } object containing the

subscribeToThreadEvents

Subscribes to events related to Threads: - `threadCreated` - `threadDeleted` - `threadStatsChanged` - `threadUpdated`

async subscribeToThreadEvents()

TypeDescription
Promise<SubscribeForChannel<"thread">> `SubscribeForChannel<'thread'>

unsubscribeFromThreadEvents

Unsubscribes from events related to given Thread.

async unsubscribeFromThreadEvents()

TypeDescription
Promise<void> a promise that resolves with void