Interface: BaseController<ModuleDefinition>
types/BaseController.BaseController
Controllers are the public interface for interacting with providence modules in your store of choice. There will only ever be one controller per registered module, thanks to the registry. The controller should not hold information that can't be reconstructed upon hot reload. It should merely be an interface for manipulating the registered module.
Type parameters
Name | Type |
---|---|
ModuleDefinition |
extends AnyModule |
Hierarchy
BaseController
Properties
attr
• attr: attrName
: Key
) => ModuleDefinition
["state"
][Key
]
Type declaration
▸ <Key
>(attrName
): ModuleDefinition
["state"
][Key
]
Retrieves a particular attribute from the state for this module.
Type parameters
Name | Type |
---|---|
Key |
extends string |
Parameters
Name | Type |
---|---|
attrName |
Key |
Returns
ModuleDefinition
["state"
][Key
]
Defined in
src/base/types/BaseController.ts:40
commit
• commit: <OutsideModuleDefinition, Key>(funcName
: Key
| `${string}/${Key}`, ...payload
: ParametersExceptFirst
<OutsideModuleDefinition
["mutations"
][Key
]>) => void
Type declaration
▸ <OutsideModuleDefinition
, Key
>(funcName
, ...payload
): void
Commits a mutation for this module.
Type parameters
Name | Type |
---|---|
OutsideModuleDefinition |
extends BaseModule <any , any , any > = ModuleDefinition |
Key |
extends string = string & keyof OutsideModuleDefinition ["mutations" ] |
Parameters
Name | Type |
---|---|
funcName |
Key | `${string}/${Key}` |
...payload |
ParametersExceptFirst <OutsideModuleDefinition ["mutations" ][Key ]> |
Returns
void
Defined in
src/base/types/BaseController.ts:44
dispatch
• dispatch: <Key>(funcName
: Key
, ...payload
: ParametersExceptFirst
<ModuleDefinition
["tasks"
][Key
]>) => ReturnType
<ModuleDefinition
["tasks"
][Key
]> | <Key>(funcName
: Key
, ...payload
: ParametersExceptFirst
<ModuleDefinition
["tasks"
][Key
]>) => ReturnType
<ModuleDefinition
["tasks"
][Key
]>
Dispatches a task for this module.
Defined in
src/base/types/BaseController.ts:48
managedNames
• managedNames: string
[]
Returns the names of all modules this module manages. For singles, that will only be the current module name. For lists, it will be the current module name and all the names of the singles it manages.
Defined in
src/base/types/BaseController.ts:36
name
• name: string
The name of the dynamically created module. This is a dot separated name. You can construct an escaped, valid name with use of the flattenNamespace function.
Defined in
src/base/types/BaseController.ts:21
namespace
• namespace: string
[]
Useful for when needing to walk through modules for an operation, namespace returns an array of strings representing this module's location in the hierarchy.
Defined in
src/base/types/BaseController.ts:31
preDestroy
• preDestroy: () => void
Type declaration
▸ (): void
A function which is run after the controller is no longer needed (because all listeners have disconnected), before it is removed from the store.
Returns
void
Defined in
src/base/types/BaseController.ts:53
rawState
• rawState: ModuleDefinition
["state"
]
The raw state of the dynamically created module. This should be a copy so mutating the output doesn't affect the state.
Defined in
src/base/types/BaseController.ts:26
uid
• Private
uid: string
An internal ID used to track this controller as a listener of single modules.