Skip to content

Commit 956ebd6

Browse files
clean up several things
1 parent 704b235 commit 956ebd6

File tree

10 files changed

+184
-170
lines changed

10 files changed

+184
-170
lines changed

packages/app/src/app/overmind/effects/live/clients.ts

Lines changed: 40 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -126,55 +126,45 @@ export class CodeSandboxOTClient extends OTClient {
126126
}
127127
}
128128

129-
export default (
130-
sendOperation: SendOperation,
131-
applyOperation: ApplyOperation
132-
): {
133-
getAll(): CodeSandboxOTClient[];
134-
get(
135-
moduleShortid: string,
136-
revision?: number,
137-
force?: boolean
138-
): CodeSandboxOTClient;
139-
create(moduleShortid: string, revision: number): CodeSandboxOTClient;
140-
clear(): void;
141-
reset(moduleShortid: string, revision: number): void;
142-
} => {
143-
const modules = new Map<string, CodeSandboxOTClient>();
144-
145-
return {
146-
getAll() {
147-
return Array.from(modules.values());
148-
},
149-
get(moduleShortid, revision = 0, force = false) {
150-
let client = modules.get(moduleShortid);
151-
152-
if (!client || force) {
153-
client = this.create(moduleShortid, revision);
154-
}
129+
const modules = new Map<string, CodeSandboxOTClient>();
155130

156-
return client!;
157-
},
158-
create(moduleShortid, initialRevision) {
159-
const client = new CodeSandboxOTClient(
160-
initialRevision || 0,
161-
moduleShortid,
162-
(revision, operation) =>
163-
sendOperation(moduleShortid, revision, operation),
164-
operation => {
165-
applyOperation(moduleShortid, operation);
166-
}
167-
);
168-
modules.set(moduleShortid, client);
169-
170-
return client;
171-
},
172-
reset(moduleShortid, revision) {
173-
modules.delete(moduleShortid);
174-
this.create(moduleShortid, revision);
175-
},
176-
clear() {
177-
modules.clear();
178-
},
179-
};
131+
export default {
132+
getAll() {
133+
return Array.from(modules.values());
134+
},
135+
get(moduleShortid, revision = 0, force = false) {
136+
let client = modules.get(moduleShortid);
137+
138+
if (!client || force) {
139+
client = this.create(moduleShortid, revision);
140+
}
141+
142+
return client!;
143+
},
144+
create(
145+
moduleShortid,
146+
initialRevision,
147+
sendOperation: SendOperation,
148+
applyOperation: ApplyOperation
149+
) {
150+
const client = new CodeSandboxOTClient(
151+
initialRevision || 0,
152+
moduleShortid,
153+
(revision, operation) =>
154+
sendOperation(moduleShortid, revision, operation),
155+
operation => {
156+
applyOperation(moduleShortid, operation);
157+
}
158+
);
159+
modules.set(moduleShortid, client);
160+
161+
return client;
162+
},
163+
reset(moduleShortid, revision) {
164+
modules.delete(moduleShortid);
165+
this.create(moduleShortid, revision);
166+
},
167+
clear() {
168+
modules.clear();
169+
},
180170
};

0 commit comments

Comments
 (0)