@pinia/root / pinia / defineStore
defineStore()
defineStore(id, options)
function defineStore<Id, S, G, A>(id, options): StoreDefinition<Id, S, G, A>
Creates a useStore
function that retrieves the store instance
Type Parameters
• Id extends string
• S extends StateTree
= object
• G extends _GettersTree
<S
> = object
• A = object
Parameters
• id: Id
id of the store (must be unique)
• options: Omit
<DefineStoreOptions
<Id
, S
, G
, A
>, "id"
>
options to define the store
Returns
StoreDefinition
<Id
, S
, G
, A
>
defineStore(options)
function defineStore<Id, S, G, A>(options): StoreDefinition<Id, S, G, A>
Creates a useStore
function that retrieves the store instance
Type Parameters
• Id extends string
• S extends StateTree
= object
• G extends _GettersTree
<S
> = object
• A = object
Parameters
• options: DefineStoreOptions
<Id
, S
, G
, A
>
options to define the store
Returns
StoreDefinition
<Id
, S
, G
, A
>
Deprecated
use defineStore(id, options)
instead
defineStore(id, storeSetup, options)
function defineStore<Id, SS>(
id,
storeSetup,
options?): StoreDefinition<Id, _ExtractStateFromSetupStore<SS>, _ExtractGettersFromSetupStore<SS>, _ExtractActionsFromSetupStore<SS>>
Creates a useStore
function that retrieves the store instance
Type Parameters
• Id extends string
• SS
Parameters
• id: Id
id of the store (must be unique)
• storeSetup
function that defines the store
• options?: DefineSetupStoreOptions
<Id
, _ExtractStateFromSetupStore
<SS
>, _ExtractGettersFromSetupStore
<SS
>, _ExtractActionsFromSetupStore
<SS
>>
extra options
Returns
StoreDefinition
<Id
, _ExtractStateFromSetupStore
<SS
>, _ExtractGettersFromSetupStore
<SS
>, _ExtractActionsFromSetupStore
<SS
>>