Skip to content

Commit

Permalink
Update storage interface so that save() is async to match indexeddb i…
Browse files Browse the repository at this point in the history
…mpl (#3221)

The only implementation of this is an async function, but I can’t await it because the interface hides the return type.

Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
  • Loading branch information
texuf and richvdh authored Apr 11, 2023
1 parent f71d86f commit a102253
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export interface IStore {
/**
* Save does nothing as there is no backing data store.
*/
save(force?: boolean): void;
save(force?: boolean): Promise<void>;

/**
* Startup does nothing.
Expand Down
4 changes: 3 additions & 1 deletion src/store/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ export class MemoryStore implements IStore {
* @param force - True to force a save (but the memory
* store still can't save anything)
*/
public save(force: boolean): void {}
public save(force: boolean): Promise<void> {
return Promise.resolve();
}

/**
* Startup does nothing as this store doesn't require starting up.
Expand Down
4 changes: 3 additions & 1 deletion src/store/stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ export class StubStore implements IStore {
/**
* Save does nothing as there is no backing data store.
*/
public save(): void {}
public save(): Promise<void> {
return Promise.resolve();
}

/**
* Startup does nothing.
Expand Down
2 changes: 1 addition & 1 deletion src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ export class SyncApi {
}

// tell databases that everything is now in a consistent state and can be saved.
this.client.store.save();
await this.client.store.save();
}
}

Expand Down

0 comments on commit a102253

Please sign in to comment.