Compare commits

...

4 Commits

Author SHA1 Message Date
fad7e0bc6b 2.0.2 2023-04-04 20:59:46 +02:00
fc4fb911ef fix(core): update 2023-04-04 20:59:45 +02:00
7e0dad1c10 2.0.1 2023-03-15 17:04:29 +01:00
0fb50714b9 fix(core): update 2023-03-15 17:04:29 +01:00
6 changed files with 3974 additions and 17987 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 Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

17979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstate", "name": "@pushrocks/smartstate",
"version": "2.0.0", "version": "2.0.2",
"private": false, "private": false,
"description": "a package that handles state in a good way", "description": "a package that handles state in a good way",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -14,17 +14,18 @@
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.61", "@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^1.0.101", "@gitzone/tsbundle": "^2.0.7",
"@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.70", "@gitzone/tstest": "^1.0.70",
"@pushrocks/tapbundle": "^5.0.3", "@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.23" "@types/node": "^18.15.11"
}, },
"dependencies": { "dependencies": {
"@pushrocks/isohash": "^2.0.0", "@pushrocks/isohash": "^2.0.0",
"@pushrocks/lik": "^5.0.4", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartjson": "^4.0.6", "@pushrocks/smartjson": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7", "@pushrocks/smartpromise": "^4.0.0",
"@pushrocks/smartrx": "^2.0.25" "@pushrocks/smartrx": "^3.0.0"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

3948
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartstate',
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 name: TStatePartName;
public state = new plugins.smartrx.rxjs.Subject<TStatePayload>(); public state = new plugins.smartrx.rxjs.Subject<TStatePayload>();
public stateStore: TStatePayload; public stateStore: TStatePayload;
private cumulativeDeferred = plugins.smartpromise.cumulativeDefer();
constructor(nameArg: TStatePartName) { constructor(nameArg: TStatePartName) {
this.name = nameArg; this.name = nameArg;
@ -79,6 +80,7 @@ export class StatePart<TStatePartName, TStatePayload> {
* dispatches an action on the statepart level * dispatches an action on the statepart level
*/ */
public async dispatchAction<T>(stateAction: StateAction<TStatePayload, T>, actionPayload: T) { public async dispatchAction<T>(stateAction: StateAction<TStatePayload, T>, actionPayload: T) {
await this.cumulativeDeferred.promise;
const newState = await stateAction.actionDef(this, actionPayload); const newState = await stateAction.actionDef(this, actionPayload);
this.setState(newState); this.setState(newState);
} }
@ -101,4 +103,11 @@ export class StatePart<TStatePartName, TStatePayload> {
subscription.unsubscribe(); subscription.unsubscribe();
return result; return result;
} }
/**
* is executed
*/
public stateSetup(funcArg: (statePartArg?: StatePart<any, TStatePayload>) => Promise<TStatePayload | void>) {
this.cumulativeDeferred.addPromise(funcArg(this));
}
} }