Skip to content

Commit

Permalink
Remove getLocalData method as it is a duplicate of serializeContents. (
Browse files Browse the repository at this point in the history
  • Loading branch information
galganif authored Nov 13, 2019
1 parent e60a9dc commit 0d950f1
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 19 deletions.
4 changes: 0 additions & 4 deletions src/runtime/storageNG/direct-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ export class DirectStore<T extends CRDTTypeRecord> extends ActiveStore<T> {
super(options);
}

async getLocalData(): Promise<CRDTData> {
return this.localModel.getData();
}

async serializeContents(): Promise<T['data']> {
await this.idle();
return this.localModel.getData();
Expand Down
10 changes: 0 additions & 10 deletions src/runtime/storageNG/reference-mode-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,6 @@ export class ReferenceModeStore<Entity extends SerializedEntity, S extends Dicti
this.containerStore.on(this.onContainerStore.bind(this));
}

async getLocalData(): Promise<CRDTData> {
const {pendingIds, model} = this.constructPendingIdsAndModel(this.containerStore.localModel.getData());
if (pendingIds.length === 0) {
return model();
} else {
return new Promise(resolve =>
this.enqueueBlockingSend(pendingIds, () => resolve(model())));
}
}

/**
* Messages are enqueued onto an object-wide queue and processed in order.
* Internally, each handler (handleContainerStore, handleBackingStore, handleProxyMessage)
Expand Down
3 changes: 1 addition & 2 deletions src/runtime/storageNG/store-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ export abstract class ActiveStore<T extends CRDTTypeRecord>
assert(this.mode === activeStore.mode);
await this.onProxyMessage({
type: ProxyMessageType.ModelUpdate,
model: await activeStore.getLocalData()
model: await activeStore.serializeContents()
});
}

async modelForSynchronization(): Promise<{}> {
return this.serializeContents();
}

abstract getLocalData(): Promise<CRDTData>;
abstract on(callback: ProxyCallback<T>): number;
abstract off(callback: number): void;
abstract async onProxyMessage(message: ProxyMessage<T>): Promise<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/storageNG/tests/reference-mode-store-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('Reference Mode Store', async () => {
// Clone.
const activeStore2 = await createReferenceModeStore();
await activeStore2.cloneFrom(activeStore);
assert.deepEqual(await activeStore2.getLocalData(), await activeStore.getLocalData());
assert.deepEqual(await activeStore2.serializeContents(), await activeStore.serializeContents());
});

it('will apply and propagate operation updates from proxies to drivers', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/storageNG/tests/store-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,11 @@ describe('Store', async () => {
const count = new CRDTCount();
count.applyOperation({type: CountOpTypes.Increment, actor: 'me', version: {from: 0, to: 1}});
await activeStore.onProxyMessage({type: ProxyMessageType.ModelUpdate, model: count.getData(), id: 1});
assert.deepEqual(await activeStore.getLocalData(), count.getData());
assert.deepEqual(await activeStore.serializeContents(), count.getData());
// Clone into another store.
const activeStore2 = await createStore().activate();
await activeStore2.cloneFrom(activeStore);
assert.deepEqual(await activeStore2.getLocalData(), count.getData());
assert.deepEqual(await activeStore2.serializeContents(), count.getData());
});

it(`won't send an update to the driver after driver-originated messages`, async () => {
Expand Down

0 comments on commit 0d950f1

Please sign in to comment.