fix(core): update
This commit is contained in:
@ -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';
|
||||
|
@ -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() {}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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() {}
|
||||
}
|
@ -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
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user