fix(core): update

This commit is contained in:
2023-10-03 19:19:54 +02:00
parent 83976fa3f4
commit 99cb86258e
3 changed files with 9 additions and 7 deletions

View File

@ -7,23 +7,24 @@ export class StatePart<TStatePartName, TStatePayload> {
public stateStore: TStatePayload;
private cumulativeDeferred = plugins.smartpromise.cumulativeDefer();
private webStoreOptions: plugins.webstore.IWebStoreOptions;
private webStore: plugins.webstore.WebStore<TStatePayload> | null = null; // Add WebStore instance
constructor(nameArg: TStatePartName, webStoreOptions?: plugins.webstore.IWebStoreOptions) {
constructor(nameArg: TStatePartName, webStoreOptionsArg?: plugins.webstore.IWebStoreOptions) {
this.name = nameArg;
// Initialize WebStore if webStoreOptions are provided
if (webStoreOptions) {
this.webStore = new plugins.webstore.WebStore<TStatePayload>(webStoreOptions);
this.initWebStore();
if (webStoreOptionsArg) {
this.webStoreOptions = webStoreOptionsArg;
}
}
/**
* initializes the webstore
*/
private async initWebStore() {
if (this.webStore) {
public async init() {
if (this.webStoreOptions) {
this.webStore = new plugins.webstore.WebStore<TStatePayload>(this.webStoreOptions);
await this.webStore.init();
const storedState = await this.webStore.get(String(this.name));
if (storedState) {