fix(core): update

This commit is contained in:
Philipp Kunz 2023-04-04 20:59:45 +02:00
parent 7e0dad1c10
commit fc4fb911ef
5 changed files with 1144 additions and 1591 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2019 Lossless GmbH (hello@lossless.com)
Copyright (c) 2019 Task Venture Capital GmbH (hello@task.vc)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -15,15 +15,16 @@
"devDependencies": {
"@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^2.0.7",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.70",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^18.15.3"
"@types/node": "^18.15.11"
},
"dependencies": {
"@pushrocks/isohash": "^2.0.0",
"@pushrocks/lik": "^6.0.2",
"@pushrocks/smartjson": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartpromise": "^4.0.0",
"@pushrocks/smartrx": "^3.0.0"
},
"files": [

2717
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -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'
}

View File

@ -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));
}
}