*/
export { setActivePinia, getActivePinia } from './rootStore'
export { createPinia } from './createPinia'
-export type { Pinia, PiniaStorePlugin, PiniaPluginContext } from './rootStore'
+export type {
+ Pinia,
+ // TODO: remove in next release
+ PiniaStorePlugin,
+ PiniaPlugin,
+ PiniaPluginContext,
+} from './rootStore'
export { defineStore, skipHydrate } from './store'
export type { StoreActions, StoreGetters, StoreState } from './store'
StateTree,
Store,
StoreGeneric,
- // TODO: remove in release
- GenericStore,
StoreDefinition,
_StoreWithGetters,
_GettersTree,
export { acceptHMRUpdate } from './hmr'
-export {
- // TODO: remove in release and deprecate PiniaStorePlugin in favor of PiniaPlugin
- PiniaPlugin,
- PiniaVuePlugin,
-} from './vue2-plugin'
+export { PiniaVuePlugin } from './vue2-plugin'
export * from './globalExtensions'
}
/**
- * Plugin to extend every store
+ * Plugin to extend every store.
*/
-export interface PiniaStorePlugin {
+export interface PiniaPlugin {
/**
* Plugin to extend every store. Returns an object to extend the store or
* nothing.
PiniaCustomProperties & PiniaCustomStateProperties
> | void
}
+
+/**
+ * Plugin to extend every store.
+ * @deprecated use PiniaPlugin instead
+ */
+export type PiniaStorePlugin = PiniaPlugin
$patch,
$reset,
$subscribe(callback, options = {}) {
- /* istanbul ignore if */
- if (__DEV__ && typeof options === 'boolean') {
- console.warn(
- `[🍍]: store.$subscribe() no longer accepts a boolean as the 2nd parameter:\n` +
- `Replace "store.$subscribe(fn, ${String(
- options
- )})" with "store.$subscribe(fn, { detached: ${String(
- options
- )} })".\nThis will fail in production.`
- )
- options = { detached: options }
- }
-
const _removeSubscription = addSubscription(
subscriptions,
callback,
- // @ts-expect-error: until the deprecation is removed
options.detached
)
const stopWatcher = scope.run(() =>
options?: { detached?: boolean } & WatchOptions
): () => void
- /**
- * Setups a callback to be called whenever the state changes. It also returns
- * a function to remove the callback. Note than when calling
- * `store.$subscribe()` inside of a component, it will be automatically
- * cleanup up when the component gets unmounted unless `detached` is set to
- * true.
- *
- * @deprecated use `store.$subscribe(fn, { detached: true })` instead.
- *
- * @param callback - callback passed to the watcher
- * @param detached - detach the subscription from the context this is called
- * from
- * @returns function that removes the watcher
- */
- $subscribe(callback: SubscriptionCallback<S>, detached?: boolean): () => void
-
/**
* @alpha Please send feedback at https://github.com/posva/pinia/issues/240
* Setups a callback to be called every time an action is about to get
_ActionsTree
>
-/**
- * Generic and type-unsafe version of Store. Doesn't fail on access with
- * strings, making it much easier to write generic functions that do not care
- * about the kind of store that is passed.
- * @deprecated Use `StoreGeneric` instead
- */
-export type GenericStore<
- Id extends string = string,
- S extends StateTree = StateTree,
- G /* extends GettersTree<S> */ = _GettersTree<S>,
- // has the actions without the context (this) for typings
- A /* extends ActionsTree */ = _ActionsTree
-> = _StoreWithState<Id, S, G, A> &
- UnwrapRef<S> &
- _StoreWithGetters<G> &
- A &
- PiniaCustomProperties<Id, S, G, A> &
- PiniaCustomStateProperties<S>
-
/**
* Return type of `defineStore()`. Function that allows instantiating a store.
*/
* Defaults to an empty object if no actions are defined.
*/
actions: A
-
- /**
- * Id of the store. Only available when the options API is used.
- *
- * @deprecated Use `store.$id` instead.
- */
- id?: Id
}