fix(core): update
This commit is contained in:
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartstate',
|
||||
version: '2.0.1',
|
||||
version: '2.0.2',
|
||||
description: 'a package that handles state in a good way'
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ export class StatePart<TStatePartName, TStatePayload> {
|
||||
public name: TStatePartName;
|
||||
public state = new plugins.smartrx.rxjs.Subject<TStatePayload>();
|
||||
public stateStore: TStatePayload;
|
||||
private cumulativeDeferred = plugins.smartpromise.cumulativeDefer();
|
||||
|
||||
constructor(nameArg: TStatePartName) {
|
||||
this.name = nameArg;
|
||||
@ -79,6 +80,7 @@ export class StatePart<TStatePartName, TStatePayload> {
|
||||
* dispatches an action on the statepart level
|
||||
*/
|
||||
public async dispatchAction<T>(stateAction: StateAction<TStatePayload, T>, actionPayload: T) {
|
||||
await this.cumulativeDeferred.promise;
|
||||
const newState = await stateAction.actionDef(this, actionPayload);
|
||||
this.setState(newState);
|
||||
}
|
||||
@ -101,4 +103,11 @@ export class StatePart<TStatePartName, TStatePayload> {
|
||||
subscription.unsubscribe();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* is executed
|
||||
*/
|
||||
public stateSetup(funcArg: (statePartArg?: StatePart<any, TStatePayload>) => Promise<TStatePayload | void>) {
|
||||
this.cumulativeDeferred.addPromise(funcArg(this));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user