ActionsTree,
SubscriptionCallbackMutation,
_UnionToTuple,
- DefineOptionStoreOptions,
DefineSetupStoreOptions,
DefineStoreOptionsInPlugin,
} from './types'
S extends StateTree,
G extends GettersTree<S>,
A extends ActionsTree
->(
- options: DefineOptionStoreOptions<Id, S, G, A>,
- pinia: Pinia
-): Store<Id, S, G, A> {
+>(options: DefineStoreOptions<Id, S, G, A>, pinia: Pinia): Store<Id, S, G, A> {
const { id, state, actions, getters } = options
function $reset() {
pinia.state.value[id] = state ? state() : {}
>(
$id: Id,
setup: () => SS,
- options: DefineStoreOptions<Id, S, G, A> = {}
+ options:
+ | DefineSetupStoreOptions<Id, S, G, A>
+ | DefineStoreOptions<Id, S, G, A> = {}
): Store<Id, S, G, A> {
const pinia = getActivePinia()
let scope!: EffectScope
- const buildState = (options as DefineOptionStoreOptions<Id, S, G, A>).state
+ const buildState = (options as DefineStoreOptions<Id, S, G, A>).state
const optionsForPlugin: DefineStoreOptionsInPlugin<Id, S, G, A> = {
actions: {} as A,
G extends GettersTree<S>,
// cannot extends ActionsTree because we loose the typings
A /* extends ActionsTree */
->(
- options: DefineOptionStoreOptions<Id, S, G, A>
-): StoreDefinition<Id, S, G, A> {
+>(options: DefineStoreOptions<Id, S, G, A>): StoreDefinition<Id, S, G, A> {
const { id } = options
function useStore(pinia?: Pinia | null) {
* Options parameter of `defineStore()`. Can be extended to augment stores with
* the plugin API.
*/
-export interface DefineOptionStoreOptions<
+export interface DefineStoreOptions<
Id extends string,
S extends StateTree,
G extends GettersTree<S>,
S extends StateTree,
G extends ActionsTree, // TODO: naming
A /* extends ActionsTree */
-> extends Pick<DefineOptionStoreOptions<Id, S, G, A>, 'hydrate'> {
+> extends Omit<
+ DefineStoreOptions<Id, S, G, A>,
+ 'actions' | 'id' | 'state' | 'getters'
+ > {
/**
* Extracted actions. Added by useStore(). SHOULD NOT be added by the user when
* creating the store. Can be used in plugins to get the list of actions in a
S extends StateTree,
G extends ActionsTree, // TODO: naming
A /* extends ActionsTree */
-> extends Omit<DefineOptionStoreOptions<Id, S, G, A>, 'id'> {
+> extends Omit<DefineStoreOptions<Id, S, G, A>, 'id'> {
/**
* Extracted object of actions. Added by useStore() when the store is built
* using the setup API, otherwise uses the one passed to `defineStore()`.
id?: Id
}
-export type DefineStoreOptions<
- Id extends string,
- S extends StateTree,
- G extends GettersTree<S>,
- A /* extends ActionsTree */
-> = DefineOptionStoreOptions<Id, S, G, A> | DefineSetupStoreOptions<Id, S, G, A>
-
export type _UnionToTuple<U> = _UnionToTupleRecursively<[], U>
type _Overwrite<T, S extends any> = {