vuex

  • Version 4.1.0
  • Published
  • 271 kB
  • 1 dependency
  • MIT license

Install

npm i vuex
yarn add vuex
pnpm add vuex

Overview

state management for Vue.js

Index

Variables

variable _default

const _default: {
Store: typeof Store;
mapState: typeof mapState;
mapMutations: typeof mapMutations;
mapGetters: typeof mapGetters;
mapActions: typeof mapActions;
createNamespacedHelpers: typeof createNamespacedHelpers;
createLogger: typeof createLogger;
};

    variable mapActions

    const mapActions: Mapper<ActionMethod> &
    MapperWithNamespace<ActionMethod> &
    MapperForAction &
    MapperForActionWithNamespace;

      variable mapGetters

      const mapGetters: Mapper<Computed> & MapperWithNamespace<Computed>;

        variable mapMutations

        const mapMutations: Mapper<MutationMethod> &
        MapperWithNamespace<MutationMethod> &
        MapperForMutation &
        MapperForMutationWithNamespace;

          variable mapState

          const mapState: Mapper<Computed> &
          MapperWithNamespace<Computed> &
          MapperForState &
          MapperForStateWithNamespace;

            variable storeKey

            const storeKey: string;

              Functions

              function createLogger

              createLogger: <S>(option?: LoggerOption<S>) => Plugin<S>;

                function createNamespacedHelpers

                createNamespacedHelpers: (namespace: string) => NamespacedMappers;

                  function createStore

                  createStore: <S>(options: StoreOptions<S>) => Store<S>;

                    function useStore

                    useStore: <S = any>(injectKey?: InjectionKey<Store<S>> | string) => Store<S>;

                      Classes

                      class Store

                      class Store<S> {}

                        constructor

                        constructor(options: StoreOptions<S>);

                          property commit

                          commit: Commit;

                            property dispatch

                            dispatch: Dispatch;

                              property getters

                              readonly getters: any;

                                property state

                                readonly state: {};

                                  method hasModule

                                  hasModule: { (path: string): boolean; (path: string[]): boolean };

                                    method hotUpdate

                                    hotUpdate: (options: {
                                    actions?: ActionTree<S, S>;
                                    mutations?: MutationTree<S>;
                                    getters?: GetterTree<S, S>;
                                    modules?: ModuleTree<S>;
                                    }) => void;

                                      method install

                                      install: (app: App, injectKey?: InjectionKey<Store<any>> | string) => void;

                                        method registerModule

                                        registerModule: {
                                        <T>(path: string, module: Module<T, S>, options?: ModuleOptions): void;
                                        <T>(path: string[], module: Module<T, S>, options?: ModuleOptions): void;
                                        };

                                          method replaceState

                                          replaceState: (state: S) => void;

                                            method subscribe

                                            subscribe: <P extends MutationPayload>(
                                            fn: (mutation: P, state: S) => any,
                                            options?: SubscribeOptions
                                            ) => () => void;

                                              method subscribeAction

                                              subscribeAction: <P extends ActionPayload>(
                                              fn: SubscribeActionOptions<P, S>,
                                              options?: SubscribeOptions
                                              ) => () => void;

                                                method unregisterModule

                                                unregisterModule: { (path: string): void; (path: string[]): void };

                                                  method watch

                                                  watch: <T>(
                                                  getter: (state: S, getters: any) => T,
                                                  cb: (value: T, oldValue: T) => void,
                                                  options?: WatchOptions
                                                  ) => () => void;

                                                    Interfaces

                                                    interface ActionContext

                                                    interface ActionContext<S, R> {}

                                                      property commit

                                                      commit: Commit;

                                                        property dispatch

                                                        dispatch: Dispatch;

                                                          property getters

                                                          getters: any;

                                                            property rootGetters

                                                            rootGetters: any;

                                                              property rootState

                                                              rootState: R;

                                                                property state

                                                                state: S;

                                                                  interface ActionObject

                                                                  interface ActionObject<S, R> {}

                                                                    property handler

                                                                    handler: ActionHandler<S, R>;

                                                                      property root

                                                                      root?: boolean;

                                                                        interface ActionPayload

                                                                        interface ActionPayload extends Payload {}

                                                                          property payload

                                                                          payload: any;

                                                                            interface ActionSubscribersObject

                                                                            interface ActionSubscribersObject<P, S> {}

                                                                              property after

                                                                              after?: ActionSubscriber<P, S>;

                                                                                property before

                                                                                before?: ActionSubscriber<P, S>;

                                                                                  property error

                                                                                  error?: ActionErrorSubscriber<P, S>;

                                                                                    interface ActionTree

                                                                                    interface ActionTree<S, R> {}

                                                                                      index signature

                                                                                      [key: string]: Action<S, R>;

                                                                                        interface Commit

                                                                                        interface Commit {}

                                                                                          call signature

                                                                                          (type: string, payload?: any, options?: CommitOptions): void;

                                                                                            call signature

                                                                                            <P extends Payload>(payloadWithType: P, options?: CommitOptions): void;

                                                                                              interface CommitOptions

                                                                                              interface CommitOptions {}

                                                                                                property root

                                                                                                root?: boolean;

                                                                                                  property silent

                                                                                                  silent?: boolean;

                                                                                                    interface Dispatch

                                                                                                    interface Dispatch {}

                                                                                                      call signature

                                                                                                      (type: string, payload?: any, options?: DispatchOptions): Promise<any>;

                                                                                                        call signature

                                                                                                        <P extends Payload>(payloadWithType: P, options?: DispatchOptions): Promise<any>;

                                                                                                          interface DispatchOptions

                                                                                                          interface DispatchOptions {}

                                                                                                            property root

                                                                                                            root?: boolean;

                                                                                                              interface GetterTree

                                                                                                              interface GetterTree<S, R> {}

                                                                                                                index signature

                                                                                                                [key: string]: Getter<S, R>;

                                                                                                                  interface Logger

                                                                                                                  interface Logger
                                                                                                                  extends Partial<Pick<Console, 'groupCollapsed' | 'group' | 'groupEnd'>> {}

                                                                                                                    method log

                                                                                                                    log: {
                                                                                                                    (message: string, color: string, payload: any): void;
                                                                                                                    (message: string): void;
                                                                                                                    };

                                                                                                                      interface LoggerOption

                                                                                                                      interface LoggerOption<S> {}

                                                                                                                        property actionFilter

                                                                                                                        actionFilter?: <P extends Payload>(action: P, state: S) => boolean;

                                                                                                                          property actionTransformer

                                                                                                                          actionTransformer?: <P extends Payload>(action: P) => any;

                                                                                                                            property collapsed

                                                                                                                            collapsed?: boolean;

                                                                                                                              property filter

                                                                                                                              filter?: <P extends Payload>(
                                                                                                                              mutation: P,
                                                                                                                              stateBefore: S,
                                                                                                                              stateAfter: S
                                                                                                                              ) => boolean;

                                                                                                                                property logActions

                                                                                                                                logActions?: boolean;

                                                                                                                                  property logger

                                                                                                                                  logger?: Logger;

                                                                                                                                    property logMutations

                                                                                                                                    logMutations?: boolean;

                                                                                                                                      property mutationTransformer

                                                                                                                                      mutationTransformer?: <P extends Payload>(mutation: P) => any;

                                                                                                                                        property transformer

                                                                                                                                        transformer?: (state: S) => any;

                                                                                                                                          interface Mapper

                                                                                                                                          interface Mapper<R> {}

                                                                                                                                            call signature

                                                                                                                                            <Key extends string>(map: Key[]): { [K in Key]: R };

                                                                                                                                              call signature

                                                                                                                                              <Map extends Record<string, string>>(map: Map): { [K in keyof Map]: R };

                                                                                                                                                interface MapperForAction

                                                                                                                                                interface MapperForAction {}

                                                                                                                                                  call signature

                                                                                                                                                  <
                                                                                                                                                  Map extends Record<
                                                                                                                                                  string,
                                                                                                                                                  (this: CustomVue, dispatch: Dispatch, ...args: any[]) => any
                                                                                                                                                  >
                                                                                                                                                  >(
                                                                                                                                                  map: Map
                                                                                                                                                  ): { [K in keyof Map]: InlineMethod<Map[K]> };

                                                                                                                                                    interface MapperForActionWithNamespace

                                                                                                                                                    interface MapperForActionWithNamespace {}

                                                                                                                                                      call signature

                                                                                                                                                      <
                                                                                                                                                      Map extends Record<
                                                                                                                                                      string,
                                                                                                                                                      (this: CustomVue, dispatch: Dispatch, ...args: any[]) => any
                                                                                                                                                      >
                                                                                                                                                      >(
                                                                                                                                                      namespace: string,
                                                                                                                                                      map: Map
                                                                                                                                                      ): { [K in keyof Map]: InlineMethod<Map[K]> };

                                                                                                                                                        interface MapperForMutation

                                                                                                                                                        interface MapperForMutation {}

                                                                                                                                                          call signature

                                                                                                                                                          <
                                                                                                                                                          Map extends Record<
                                                                                                                                                          string,
                                                                                                                                                          (this: CustomVue, commit: Commit, ...args: any[]) => any
                                                                                                                                                          >
                                                                                                                                                          >(
                                                                                                                                                          map: Map
                                                                                                                                                          ): { [K in keyof Map]: InlineMethod<Map[K]> };

                                                                                                                                                            interface MapperForMutationWithNamespace

                                                                                                                                                            interface MapperForMutationWithNamespace {}

                                                                                                                                                              call signature

                                                                                                                                                              <
                                                                                                                                                              Map extends Record<
                                                                                                                                                              string,
                                                                                                                                                              (this: CustomVue, commit: Commit, ...args: any[]) => any
                                                                                                                                                              >
                                                                                                                                                              >(
                                                                                                                                                              namespace: string,
                                                                                                                                                              map: Map
                                                                                                                                                              ): { [K in keyof Map]: InlineMethod<Map[K]> };

                                                                                                                                                                interface MapperForState

                                                                                                                                                                interface MapperForState {}

                                                                                                                                                                  call signature

                                                                                                                                                                  <
                                                                                                                                                                  S,
                                                                                                                                                                  Map extends Record<
                                                                                                                                                                  string,
                                                                                                                                                                  (this: CustomVue, state: S, getters: any) => any
                                                                                                                                                                  > = {}
                                                                                                                                                                  >(
                                                                                                                                                                  map: Map
                                                                                                                                                                  ): { [K in keyof Map]: InlineComputed<Map[K]> };

                                                                                                                                                                    interface MapperForStateWithNamespace

                                                                                                                                                                    interface MapperForStateWithNamespace {}

                                                                                                                                                                      call signature

                                                                                                                                                                      <
                                                                                                                                                                      S,
                                                                                                                                                                      Map extends Record<
                                                                                                                                                                      string,
                                                                                                                                                                      (this: CustomVue, state: S, getters: any) => any
                                                                                                                                                                      > = {}
                                                                                                                                                                      >(
                                                                                                                                                                      namespace: string,
                                                                                                                                                                      map: Map
                                                                                                                                                                      ): { [K in keyof Map]: InlineComputed<Map[K]> };

                                                                                                                                                                        interface MapperWithNamespace

                                                                                                                                                                        interface MapperWithNamespace<R> {}

                                                                                                                                                                          call signature

                                                                                                                                                                          <Key extends string>(namespace: string, map: Key[]): { [K in Key]: R };

                                                                                                                                                                            call signature

                                                                                                                                                                            <Map extends Record<string, string>>(namespace: string, map: Map): {
                                                                                                                                                                            [K in keyof Map]: R;
                                                                                                                                                                            };

                                                                                                                                                                              interface Module

                                                                                                                                                                              interface Module<S, R> {}

                                                                                                                                                                                property actions

                                                                                                                                                                                actions?: ActionTree<S, R>;

                                                                                                                                                                                  property getters

                                                                                                                                                                                  getters?: GetterTree<S, R>;

                                                                                                                                                                                    property modules

                                                                                                                                                                                    modules?: ModuleTree<R>;

                                                                                                                                                                                      property mutations

                                                                                                                                                                                      mutations?: MutationTree<S>;

                                                                                                                                                                                        property namespaced

                                                                                                                                                                                        namespaced?: boolean;

                                                                                                                                                                                          property state

                                                                                                                                                                                          state?: S | (() => S);

                                                                                                                                                                                            interface ModuleOptions

                                                                                                                                                                                            interface ModuleOptions {}

                                                                                                                                                                                              property preserveState

                                                                                                                                                                                              preserveState?: boolean;

                                                                                                                                                                                                interface ModuleTree

                                                                                                                                                                                                interface ModuleTree<R> {}

                                                                                                                                                                                                  index signature

                                                                                                                                                                                                  [key: string]: Module<any, R>;

                                                                                                                                                                                                    interface MutationPayload

                                                                                                                                                                                                    interface MutationPayload extends Payload {}

                                                                                                                                                                                                      property payload

                                                                                                                                                                                                      payload: any;

                                                                                                                                                                                                        interface MutationTree

                                                                                                                                                                                                        interface MutationTree<S> {}

                                                                                                                                                                                                          index signature

                                                                                                                                                                                                          [key: string]: Mutation<S>;

                                                                                                                                                                                                            interface NamespacedMappers

                                                                                                                                                                                                            interface NamespacedMappers {}

                                                                                                                                                                                                              property mapActions

                                                                                                                                                                                                              mapActions: Mapper<ActionMethod> & MapperForAction;

                                                                                                                                                                                                                property mapGetters

                                                                                                                                                                                                                mapGetters: Mapper<Computed>;

                                                                                                                                                                                                                  property mapMutations

                                                                                                                                                                                                                  mapMutations: Mapper<MutationMethod> & MapperForMutation;

                                                                                                                                                                                                                    property mapState

                                                                                                                                                                                                                    mapState: Mapper<Computed> & MapperForState;

                                                                                                                                                                                                                      interface Payload

                                                                                                                                                                                                                      interface Payload {}

                                                                                                                                                                                                                        property type

                                                                                                                                                                                                                        type: string;

                                                                                                                                                                                                                          interface StoreOptions

                                                                                                                                                                                                                          interface StoreOptions<S> {}

                                                                                                                                                                                                                            property actions

                                                                                                                                                                                                                            actions?: ActionTree<S, S>;

                                                                                                                                                                                                                              property devtools

                                                                                                                                                                                                                              devtools?: boolean;

                                                                                                                                                                                                                                property getters

                                                                                                                                                                                                                                getters?: GetterTree<S, S>;

                                                                                                                                                                                                                                  property modules

                                                                                                                                                                                                                                  modules?: ModuleTree<S>;

                                                                                                                                                                                                                                    property mutations

                                                                                                                                                                                                                                    mutations?: MutationTree<S>;

                                                                                                                                                                                                                                      property plugins

                                                                                                                                                                                                                                      plugins?: Plugin<S>[];

                                                                                                                                                                                                                                        property state

                                                                                                                                                                                                                                        state?: S | (() => S);

                                                                                                                                                                                                                                          property strict

                                                                                                                                                                                                                                          strict?: boolean;

                                                                                                                                                                                                                                            interface SubscribeOptions

                                                                                                                                                                                                                                            interface SubscribeOptions {}

                                                                                                                                                                                                                                              property prepend

                                                                                                                                                                                                                                              prepend?: boolean;

                                                                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                                                                type Action

                                                                                                                                                                                                                                                type Action<S, R> = ActionHandler<S, R> | ActionObject<S, R>;

                                                                                                                                                                                                                                                  type ActionErrorSubscriber

                                                                                                                                                                                                                                                  type ActionErrorSubscriber<P, S> = (action: P, state: S, error: Error) => any;

                                                                                                                                                                                                                                                    type ActionHandler

                                                                                                                                                                                                                                                    type ActionHandler<S, R> = (
                                                                                                                                                                                                                                                    this: Store<R>,
                                                                                                                                                                                                                                                    injectee: ActionContext<S, R>,
                                                                                                                                                                                                                                                    payload?: any
                                                                                                                                                                                                                                                    ) => any;

                                                                                                                                                                                                                                                      type ActionMethod

                                                                                                                                                                                                                                                      type ActionMethod = (...args: any[]) => Promise<any>;

                                                                                                                                                                                                                                                        type ActionSubscriber

                                                                                                                                                                                                                                                        type ActionSubscriber<P, S> = (action: P, state: S) => any;

                                                                                                                                                                                                                                                          type Computed

                                                                                                                                                                                                                                                          type Computed = () => any;

                                                                                                                                                                                                                                                            type CustomVue

                                                                                                                                                                                                                                                            type CustomVue = ComponentPublicInstance & Record<string, any>;

                                                                                                                                                                                                                                                              type Getter

                                                                                                                                                                                                                                                              type Getter<S, R> = (state: S, getters: any, rootState: R, rootGetters: any) => any;

                                                                                                                                                                                                                                                                type InlineComputed

                                                                                                                                                                                                                                                                type InlineComputed<T extends Function> = T extends (...args: any[]) => infer R
                                                                                                                                                                                                                                                                ? () => R
                                                                                                                                                                                                                                                                : never;

                                                                                                                                                                                                                                                                  type InlineMethod

                                                                                                                                                                                                                                                                  type InlineMethod<T extends (fn: any, ...args: any[]) => any> = T extends (
                                                                                                                                                                                                                                                                  fn: any,
                                                                                                                                                                                                                                                                  ...args: infer Args
                                                                                                                                                                                                                                                                  ) => infer R
                                                                                                                                                                                                                                                                  ? (...args: Args) => R
                                                                                                                                                                                                                                                                  : never;

                                                                                                                                                                                                                                                                    type Mutation

                                                                                                                                                                                                                                                                    type Mutation<S> = (state: S, payload?: any) => any;

                                                                                                                                                                                                                                                                      type MutationMethod

                                                                                                                                                                                                                                                                      type MutationMethod = (...args: any[]) => void;

                                                                                                                                                                                                                                                                        type Plugin

                                                                                                                                                                                                                                                                        type Plugin<S> = (store: Store<S>) => any;

                                                                                                                                                                                                                                                                          type SubscribeActionOptions

                                                                                                                                                                                                                                                                          type SubscribeActionOptions<P, S> =
                                                                                                                                                                                                                                                                          | ActionSubscriber<P, S>
                                                                                                                                                                                                                                                                          | ActionSubscribersObject<P, S>;

                                                                                                                                                                                                                                                                            Package Files (3)

                                                                                                                                                                                                                                                                            Dependencies (1)

                                                                                                                                                                                                                                                                            Dev Dependencies (37)

                                                                                                                                                                                                                                                                            Peer Dependencies (1)

                                                                                                                                                                                                                                                                            Badge

                                                                                                                                                                                                                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/vuex.

                                                                                                                                                                                                                                                                            • Markdown
                                                                                                                                                                                                                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/vuex)
                                                                                                                                                                                                                                                                            • HTML
                                                                                                                                                                                                                                                                              <a href="https://www.jsdocs.io/package/vuex"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>