Compare commits

..

2 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
5 changed files with 1145 additions and 1592 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

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstate", "name": "@pushrocks/smartstate",
"version": "2.0.1", "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",
@ -15,15 +15,16 @@
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.61", "@gitzone/tsbuild": "^2.1.61",
"@gitzone/tsbundle": "^2.0.7", "@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": "^18.15.3" "@types/node": "^18.15.11"
}, },
"dependencies": { "dependencies": {
"@pushrocks/isohash": "^2.0.0", "@pushrocks/isohash": "^2.0.0",
"@pushrocks/lik": "^6.0.2", "@pushrocks/lik": "^6.0.2",
"@pushrocks/smartjson": "^5.0.5", "@pushrocks/smartjson": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7", "@pushrocks/smartpromise": "^4.0.0",
"@pushrocks/smartrx": "^3.0.0" "@pushrocks/smartrx": "^3.0.0"
}, },
"files": [ "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 = { export const commitinfo = {
name: '@pushrocks/smartstate', name: '@pushrocks/smartstate',
version: '2.0.1', version: '2.0.2',
description: 'a package that handles state in a good way' 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));
}
} }