Compare commits

...

6 Commits

Author SHA1 Message Date
a21131eaf6 2.0.6 2023-04-13 14:22:32 +02:00
c4b214a308 fix(core): update 2023-04-13 14:22:31 +02:00
6db03eee83 2.0.5 2023-04-12 20:34:34 +02:00
efc5b54d2e fix(core): update 2023-04-12 20:34:34 +02:00
9860e43398 2.0.4 2023-04-04 21:52:27 +02:00
234117c8dd fix(core): update 2023-04-04 21:52:27 +02:00
4 changed files with 1002 additions and 532 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstate", "name": "@pushrocks/smartstate",
"version": "2.0.3", "version": "2.0.6",
"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,11 +14,11 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.61", "@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsbundle": "^2.0.7", "@gitzone/tsbundle": "^2.0.7",
"@gitzone/tsrun": "^1.2.39", "@gitzone/tsrun": "^1.2.39",
"@gitzone/tstest": "^1.0.70", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^5.0.3", "@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.15.11" "@types/node": "^18.15.11"
}, },
"dependencies": { "dependencies": {

1504
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.3', version: '2.0.6',
description: 'a package that handles state in a good way' description: 'a package that handles state in a good way'
} }

View File

@ -37,7 +37,7 @@ export class StatePart<TStatePartName, TStatePayload> {
if ( if (
this.stateStore && this.stateStore &&
this.lastStateNotificationPayloadHash && this.lastStateNotificationPayloadHash &&
createStateHash(this.stateStore) === createStateHash(this.lastStateNotificationPayloadHash) createStateHash(this.stateStore) === this.lastStateNotificationPayloadHash
) { ) {
return; return;
} else { } else {
@ -47,6 +47,14 @@ export class StatePart<TStatePartName, TStatePayload> {
} }
private lastStateNotificationPayloadHash: any; private lastStateNotificationPayloadHash: any;
/**
* creates a cumulative notification by adding a change notification at the end of the call stack;
*/
public notifyChangeCumulative() {
// TODO: check viability
setTimeout(() => this.state.next(this.stateStore), 0);
}
/** /**
* selects a state or a substate * selects a state or a substate
*/ */
@ -56,7 +64,6 @@ export class StatePart<TStatePartName, TStatePayload> {
if (!selectorFn) { if (!selectorFn) {
selectorFn = (state: TStatePayload) => <T>(<any>state); selectorFn = (state: TStatePayload) => <T>(<any>state);
} }
const mapped = this.state.pipe( const mapped = this.state.pipe(
plugins.smartrx.rxjs.ops.startWith(this.getState()), plugins.smartrx.rxjs.ops.startWith(this.getState()),
plugins.smartrx.rxjs.ops.map((stateArg) => { plugins.smartrx.rxjs.ops.map((stateArg) => {
@ -67,7 +74,6 @@ export class StatePart<TStatePartName, TStatePayload> {
} }
}) })
); );
return mapped; return mapped;
} }
@ -111,9 +117,11 @@ export class StatePart<TStatePartName, TStatePayload> {
/** /**
* is executed * is executed
*/ */
public stateSetup( public async stateSetup(
funcArg: (statePartArg?: StatePart<any, TStatePayload>) => Promise<TStatePayload | void> funcArg: (statePartArg?: StatePart<any, TStatePayload>) => Promise<TStatePayload>
) { ) {
this.cumulativeDeferred.addPromise(funcArg(this)); const resultPromise = funcArg(this);
this.cumulativeDeferred.addPromise(resultPromise);
this.setState(await resultPromise);
} }
} }