fix(core): update
This commit is contained in:
parent
c549d06a6b
commit
f167800113
@ -5,12 +5,12 @@ import { StatePart } from './smartstate.classes.statepart';
|
|||||||
* Smartstate takes care of providing state
|
* Smartstate takes care of providing state
|
||||||
*/
|
*/
|
||||||
export class Smartstate<StatePartNameType> {
|
export class Smartstate<StatePartNameType> {
|
||||||
public statePartMap: { [key: string]: StatePart<StatePartNameType, any> } = {};
|
public statePartMap: { [key: string]: StatePart<StatePartNameType, unknown> } = {};
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
public getStatePart<PayloadType>(
|
public getStatePart<PayloadType>(
|
||||||
statePartNameArg: StatePartNameType,
|
statePartNameArg: string & StatePartNameType,
|
||||||
initialArg?: PayloadType
|
initialArg?: PayloadType
|
||||||
): StatePart<StatePartNameType, PayloadType> {
|
): StatePart<StatePartNameType, PayloadType> {
|
||||||
if (this.statePartMap[statePartNameArg as any]) {
|
if (this.statePartMap[statePartNameArg as any]) {
|
||||||
@ -19,7 +19,7 @@ export class Smartstate<StatePartNameType> {
|
|||||||
`${statePartNameArg} already exists, yet you try to set an initial state again`
|
`${statePartNameArg} already exists, yet you try to set an initial state again`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return this.statePartMap[statePartNameArg as any];
|
return this.statePartMap[statePartNameArg] as StatePart<StatePartNameType, PayloadType>;
|
||||||
} else {
|
} else {
|
||||||
if (!initialArg) {
|
if (!initialArg) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
Loading…
Reference in New Issue
Block a user