fix(core): update
This commit is contained in:
parent
83976fa3f4
commit
99cb86258e
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartstate',
|
||||
version: '2.0.14',
|
||||
version: '2.0.15',
|
||||
description: 'a package that handles state in a good way'
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ export class Smartstate<StatePartNameType> {
|
||||
storeName: statePartName as any,
|
||||
} : null
|
||||
);
|
||||
await newState.init();
|
||||
const currentState = newState.getState();
|
||||
await newState.setState({
|
||||
...initialPayloadArg,
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user