Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support asynchronous externals.localStorage API #265

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions sdk/src/core/Cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default class Cache {
}

public async setItem(key, data) {
this.setItemSync(key, data);
await this._externals.localStorage.setItem(this._prefixKey(key), JSON.stringify(data));
//this.setItemSync(key, data);
}

public removeItemSync(key) {
Expand All @@ -32,7 +33,8 @@ export default class Cache {
}

public async removeItem(key) {
await this.removeItemSync(key);
await this._externals.localStorage.removeItem(this._prefixKey(key));
//await this.removeItemSync(key);
}

public getItemSync(key) {
Expand All @@ -42,7 +44,10 @@ export default class Cache {
}

public async getItem(key) {
return this.getItemSync(key);
const item = await this._externals.localStorage.getItem(this._prefixKey(key));
if (!item) {return null;}
return JSON.parse(item);
// return this.getItemSync(key);
}

private async _keys(): Promise<string[]> {
Expand Down
Loading