Interface: CommentsEngine
@roomful/core / CommentsEngine
Interface: CommentsEngine
Section titled “Interface: CommentsEngine”Defined in: packages/core/src/types.ts:2120
Exposes collaborative comment threads for a room. Threads are synced collaborative state, shared across peers over the room’s existing CRDT channel.
Methods
Section titled “Methods”add(
input):Promise<CommentThread>
Defined in: packages/core/src/types.ts:2128
Opens a new thread authored by the local peer at anchor. The thread id
and createdAt are generated.
Parameters
Section titled “Parameters”The thread anchor and root comment body.
anchor
Section titled “anchor”string
Returns
Section titled “Returns”Promise<CommentThread>
A promise resolving to the created thread.
getAll()
Section titled “getAll()”getAll():
CommentThread[]
Defined in: packages/core/src/types.ts:2145
Returns every thread, oldest first.
Returns
Section titled “Returns”The current threads.
getByElement()
Section titled “getByElement()”getByElement(
elementId):CommentThread[]
Defined in: packages/core/src/types.ts:2154
Returns the threads anchored to elementId (element or text-range
anchors).
Parameters
Section titled “Parameters”elementId
Section titled “elementId”string
The element id to filter by.
Returns
Section titled “Returns”The matching threads.
getOpen()
Section titled “getOpen()”getOpen():
CommentThread[]
Defined in: packages/core/src/types.ts:2161
Returns the unresolved threads.
Returns
Section titled “Returns”The open threads.
subscribe()
Section titled “subscribe()”subscribe(
callback):Unsubscribe
Defined in: packages/core/src/types.ts:2170
Subscribes to thread changes. Fires immediately with the current threads, then on every local or remote mutation.
Parameters
Section titled “Parameters”callback
Section titled “callback”(threads) => void
The callback invoked with the latest threads.
Returns
Section titled “Returns”A function that removes the listener.
thread()
Section titled “thread()”thread(
id):CommentThreadHandle
Defined in: packages/core/src/types.ts:2138
Resolves a handle for operating on the thread with id. The handle
methods no-op against an unknown id until it surfaces, then resolve to the
latest thread.
Parameters
Section titled “Parameters”string
The thread id.
Returns
Section titled “Returns”A handle exposing reply, resolve, and reopen.