Skip to content

Commit 5bdefa3

Browse files
committed
adjusted optional parameter
1 parent 006ffde commit 5bdefa3

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/collab-client/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export { collab, collabKey } from "./plugin";
1515
export interface CommitsListener {
1616
listen: (
1717
editorState: EditorState,
18-
options?: { signal?: AbortSignal },
18+
options?: { signal?: AbortSignal | undefined },
1919
) => AsyncIterableIterator<Commit[]>;
2020
}
2121

@@ -63,8 +63,9 @@ export class CollabClient {
6363
}
6464

6565
async listen(editorState: EditorState, signal?: AbortSignal) {
66-
let options = signal ? { signal } : {};
67-
for await (const newCommits of this.listener.listen(editorState, options)) {
66+
for await (const newCommits of this.listener.listen(editorState, {
67+
signal,
68+
})) {
6869
if (signal && signal.aborted) break;
6970
this.receiveCommits(newCommits);
7071
}
@@ -93,7 +94,7 @@ export class LongPollListener {
9394
this.headers = headers;
9495
}
9596

96-
async *listen(editorState: EditorState, options: { signal?: AbortSignal } = {}) {
97+
async *listen(editorState: EditorState, options: { signal?: AbortSignal | undefined } = {}) {
9798
const seen = new Set<string>();
9899
let version = getVersion(editorState);
99100
if (version === undefined) {

packages/presence-client/src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export { type PresenceIndicator, type PresenceClientConfig };
1313
export interface IndicatorListener {
1414
listen: (
1515
clientId: string,
16-
options?: { signal?: AbortSignal },
16+
options?: { signal?: AbortSignal | undefined },
1717
) => AsyncIterableIterator<Record<string, PresenceIndicator>>;
1818
}
1919

@@ -77,8 +77,9 @@ export class PresenceClient {
7777
}
7878

7979
async listen(signal?: AbortSignal) {
80-
const options = signal ? { signal } : {};
81-
for await (const indicators of this.listener.listen(this.clientId, options)) {
80+
for await (const indicators of this.listener.listen(this.clientId, {
81+
signal,
82+
})) {
8283
if (signal && signal.aborted) break;
8384
this.receiveIndicators(indicators);
8485
}
@@ -107,7 +108,7 @@ export class LongPollListener {
107108
this.headers = headers;
108109
}
109110

110-
async *listen(clientId: string, options: { signal?: AbortSignal } = {}) {
111+
async *listen(clientId: string, options: { signal?: AbortSignal | undefined } = {}) {
111112
let refs: Record<string, string> = {};
112113

113114
while (!options?.signal || !options.signal.aborted) {

0 commit comments

Comments
 (0)