Skip to content

Commit fd61e85

Browse files
committed
feat: 🎸 simplify repo start method
1 parent ee50fa4 commit fd61e85

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

src/json-crdt-repo/__tests__/testbed.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ export class BrowserTabTestbed {
7171
onSyncError: (error) => console.error(error),
7272
...opts,
7373
});
74-
repo.start();
7574
return new LocalRepoTestbed(this, repo);
7675
}
7776

src/json-crdt-repo/local/level/LevelLocalRepo.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,18 +194,14 @@ export class LevelLocalRepo implements LocalRepo {
194194
this.connected$ = opts.connected$ ?? new BehaviorSubject(true);
195195
this.pubsub = opts.pubsub ?? pubsub('level-local-repo');
196196
this.cipher = opts.cipher;
197+
this._conSub = this.connected$.subscribe((connected) => {
198+
if (connected && !this._remoteSyncLoopActive) this.runRemoteSyncLoop();
199+
});
197200
}
198201

199202
private _conSub: Subscription | undefined = undefined;
200203
private _stopped = false;
201204

202-
@once
203-
public start(): void {
204-
this._conSub = this.connected$.subscribe((connected) => {
205-
if (!this._remoteSyncLoopActive) this.runRemoteSyncLoop();
206-
});
207-
}
208-
209205
@once
210206
public stop(): void {
211207
this._remoteSyncLoopActive = false;

src/json-crdt-repo/local/level/__tests__/setup.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export const setup = async (
4646
return {kv, sid, local, pubsub, stop};
4747
};
4848
const {sid, local, pubsub, stop} = createLocal();
49-
local.start();
5049
const createRemote = (localOpts: Partial<LevelLocalRepoOpts> = {}) => {
5150
const sid = localOpts.sid ?? 123456789;
5251
const busName = 'test-' + id;

0 commit comments

Comments
 (0)