fix(core): update

This commit is contained in:
2022-01-24 06:39:36 +01:00
parent be505ee915
commit f7887a6663
12 changed files with 19435 additions and 3516 deletions

View File

@ -1,5 +1,3 @@
export * from './smartstate.classes.smartstate';
export * from './smartstate.classes.statepart';
export * from './smartstate.classes.statecollection';
export * from './smartstate.classes.stateaction';
export * from './smartstate.classes.stateobservable';

View File

@ -5,7 +5,7 @@ import { StatePart } from './smartstate.classes.statepart';
* Smartstate takes care of providing state
*/
export class Smartstate<StatePartNameType> {
public statePartMap: { [key: string]: StatePart<StatePartNameType, unknown> } = {};
public statePartMap: { [key: string]: StatePart<StatePartNameType, any> } = {};
constructor() {}

View File

@ -1,12 +0,0 @@
import * as plugins from './smartstate.plugins';
import { StatePart } from './smartstate.classes.statepart';
/**
* A StatePartCollection is a collection of StateParts.
* It can be used for expressing interest in a certain set of StateParts.
*/
export class StatePartCollection<StatePartNameType, T> extends StatePart<StatePartNameType, T> {
constructor(nameArg: StatePartNameType) {
super(nameArg);
}
}

View File

@ -1,13 +0,0 @@
import * as plugins from './smartstate.plugins';
/**
* State observable observes a StatePart and notifies everyone interested
*/
export class StateObservable {
/**
* creates an observable from a StateCollection
*/
public static fromStatePartCollection(filterArg?: () => any) {}
constructor() {}
}

View File

@ -30,8 +30,17 @@ export class StatePart<TStatePartName, TStatePayload> {
* notifies of a change on the state
*/
public notifyChange() {
const createStateHash = (stateArg: any) => {
return plugins.isohash.sha256FromString(plugins.smartjson.stringify(stateArg));
};
if (this.stateStore && this.lastStateNotificationPayloadHash && createStateHash(this.stateStore) === createStateHash(this.lastStateNotificationPayloadHash)) {
return;
} else {
this.lastStateNotificationPayloadHash = this.stateStore;
}
this.state.next(this.stateStore);
}
private lastStateNotificationPayloadHash: any;
/**
* selects a state or a substate

View File

@ -1,4 +1,7 @@
import * as isohash from '@pushrocks/isohash';
import * as smartjson from '@pushrocks/smartjson';
import * as smartobject from '@pushrocks/smartobject';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrx from '@pushrocks/smartrx';
export { smartpromise, smartrx };
export { isohash, smartjson, smartobject, smartpromise, smartrx };