Compare commits

...

2 Commits

Author SHA1 Message Date
9413c5bcdc 1.0.19 2020-11-29 23:31:32 +00:00
1d5fb320f4 fix(core): update 2020-11-29 23:31:31 +00:00
3 changed files with 5 additions and 4 deletions

2
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/smartstate", "name": "@pushrocks/smartstate",
"version": "1.0.18", "version": "1.0.19",
"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",

View File

@ -11,10 +11,11 @@ export class Smartstate<StatePartNameType> {
public getStatePart<PayloadType>( public getStatePart<PayloadType>(
statePartNameArg: string & StatePartNameType, statePartNameArg: string & StatePartNameType,
initialArg?: PayloadType initialArg?: PayloadType,
initMode?: 'soft' | 'mandatory'
): StatePart<StatePartNameType, PayloadType> { ): StatePart<StatePartNameType, PayloadType> {
if (this.statePartMap[statePartNameArg as any]) { if (this.statePartMap[statePartNameArg as any]) {
if (initialArg && Object.keys(initialArg).length > 0) { if (initialArg && (!initMode || initMode !== 'soft')) {
throw new Error( throw new Error(
`${statePartNameArg} already exists, yet you try to set an initial state again` `${statePartNameArg} already exists, yet you try to set an initial state again`
); );