fix(core): update
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user