fix(core): update

This commit is contained in:
Philipp Kunz 2020-11-29 23:31:31 +00:00
parent 69e905ad76
commit 1d5fb320f4

View File

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