Called on any errors loading/saving/etc, should be used to notify the user.
Optional
onExport?: (res: object) => voidCalled when a manager is exported. Can be used to actually do the export.
Optional
onParse?: (parsed: object) => undefined | ErrorCalled when a manager is parsed from storage after being sucessfully JSON.parsed.
You can validate the parsed object here so it's in the correct shape to pass to createManager
.
If you return an error, onError
will be called and createManager
will be skipped.
Optional
onSave?: (clone: DeepPartial<Manager>) => voidCalled when a manager is saved or exported. It's called with the cloned version of the manager that has been stripped of properties that should not be saved (see managerToStorableClone).
You can delete/add properties here (it will not modify the original manager).
Optional
onSetActiveManager?: (name: string) => voidCalled when the active manager is set. Can be used to update your state.
Optional
onSetManager?: (name: string, clone: Manager) => voidCalled when a manager is set. Can be used to update your state.
Optional
onSetManagerNames?: (names: string[]) => voidCalled when the manager names are set. Can be used to update your state.
Readonly
activeAll new managers will be created using this function. It should be capable of taking as little information as {name}
(when a new manager is created) and returining a full manger.
It's suggested you not do validation here, use the onParse
hook instead.
If you return an error, onError
will be called, and no manager will be created.
A debounced version of the save function. Is already bound to the instance.
Called on any errors loading/saving/etc, should be used to notify the user.
Optional
onExport?: (res: object) => voidCalled when a manager is exported. Can be used to actually do the export.
Optional
onParse?: (parsed: object) => undefined | ErrorCalled when a manager is parsed from storage after being sucessfully JSON.parsed.
You can validate the parsed object here so it's in the correct shape to pass to createManager
.
If you return an error, onError
will be called and createManager
will be skipped.
Optional
onSave?: (clone: DeepPartial<Manager>) => voidCalled when a manager is saved or exported. It's called with the cloned version of the manager that has been stripped of properties that should not be saved (see managerToStorableClone).
You can delete/add properties here (it will not modify the original manager).
Optional
onSetActiveManager?: (name: string) => voidCalled when the active manager is set. Can be used to update your state.
Optional
onSetManager?: (name: string, clone: Manager) => voidCalled when a manager is set. Can be used to update your state.
Optional
onSetManagerNames?: (names: string[]) => voidCalled when the manager names are set. Can be used to update your state.
Readonly
managerReadonly
managersProtected
addClears all managers and resets the state. init
must be called again if you want to use the class instance again.
Protected
loadProtected
notifyProtected
removeOptional
clone: anyProtected
storageProtected
storageProtected
storage
All new managers will be created using this function. It should be capable of taking as little information as
{name}
(when a new manager is created) and returining a full manger.It's suggested you not do validation here, use the
onParse
hook instead.If you return an error,
onError
will be called, and no manager will be created.