Compare commits

...

2 Commits

Author SHA1 Message Date
993a100eae 1.0.20 2020-11-29 23:33:56 +00:00
29f0307ef8 fix(core): update 2020-11-29 23:33:55 +00:00
3 changed files with 12 additions and 3 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstate",
"version": "1.0.19",
"version": "1.0.20",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartstate",
"version": "1.0.19",
"version": "1.0.20",
"private": false,
"description": "a package that handles state in a good way",
"main": "dist_ts/index.js",

View File

@ -9,10 +9,19 @@ export class Smartstate<StatePartNameType> {
constructor() {}
/**
* Allows getting and initializing a new statepart
* initMode === 'soft' it will allow existing stateparts
* initMode === 'mandatory' will fail if there is an exiting statepart
* initMode === 'force' will overwrite any existing statepart
* @param statePartNameArg
* @param initialArg
* @param initMode
*/
public getStatePart<PayloadType>(
statePartNameArg: string & StatePartNameType,
initialArg?: PayloadType,
initMode?: 'soft' | 'mandatory'
initMode?: 'soft' | 'mandatory' | 'force'
): StatePart<StatePartNameType, PayloadType> {
if (this.statePartMap[statePartNameArg as any]) {
if (initialArg && (!initMode || initMode !== 'soft')) {