How to use the vuex.Store function in vuex

To help you get started, we’ve selected a few vuex examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github championswimmer / vuex-module-decorators / test / muation_and_action.ts View on Github external
}

  @Action
  fetchCountDelta() {
    this.context.commit('incrCount', 5)
  }

  @Action({ rawError: true })
  async incrCountAction(payload: number) {
    const context = this.context
    await this.context.dispatch('getCountDelta')
    expect(this.context).to.equal(context)
  }
}

const store = new Vuex.Store({
  modules: {
    mm: MyModule
  }
})

describe('dispatching action which mutates works', () => {
  it('should update count', async function() {
    await store.dispatch('getCountDelta')
    expect(parseInt(store.state.mm.count)).to.equal(5)
  })
  it('should update count (sync)', async function() {
    store.dispatch('fetchCountDelta')
    expect(parseInt(store.state.mm.count)).to.equal(10)
  })
})
github wmde / FundraisingFrontend / skins / cat17 / address-form / src / __tests__ / components / AddressForm.spec.ts View on Github external
city: Validity.INCOMPLETE,
				country: Validity.VALID,
				addressType: Validity.VALID,
				receiptOptOut: Validity.VALID
			}
		},
		actions = {
			validateInput: jest.fn(),
			storeAddressFields: jest.fn()
		}
		getters = {
			validity: () => jest.fn(),
			invalidFields: jest.fn(),
			allFieldsAreValid: jest.fn()
		}
		store = new Vuex.Store({
			state,
			actions,
			getters
		});
	})
github Nirongxu / vue-xuAdmin / src / vuex / index.js View on Github external
import Vue from 'vue'
import Vuex from 'vuex'
import Cookies from 'js-cookie'
import routerData from './modules/routerData'
import role from './modules/role'
import layout from './modules/layout/index'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    token: Cookies.get('token')
  },
  mutations: {
    setToken (state, token) {
      state.token = token
      Cookies.set('token', token ,{ expires: 1/24 });
    }
  },
  actions: {
    setToken ({commit}, token) {
      return new Promise((resolve, reject) => {
        commit('setToken', token)
        resolve()
      })
    }
github eggplanetio / tidytab / app / store / index.js View on Github external
import packageJson from '../../package.json'

import {
  filteredAndSorted,
  groupByDate,
  filteredUsingSearchQuery
} from '../../lib/tab-group-helpers'

Vue.use(Vuex)
const chromep = new ChromePromise()

export const THEMES = ['dark', 'light']
export const POST_TIDY_BEHAVIORS = ['dashboard', 'new-tab']
export const TAB_GROUP_VIEWS = ['default', 'group-by-date']

const store = new Vuex.Store({
  state: {
    version: packageJson.version,
    stateVersion: packageJson.version.split('.')[0],
    data: {
      tabGroups: []
    },
    searchQuery: '',
    theme: '',
    bookmarkFolderId: null,
    postTidyBehavior: null,
    silentlyRejectDuplicates: null,
    tabGroupView: null
  },

  actions: {
    async SAVE_TAB_GROUP (
github quasarframework / quasar-play / src / store / index.js View on Github external
export default function () {
  const Store = new Vuex.Store({
    modules: {
      showcase,
      layoutDemo
    }
  })

  if (process.env.DEV && module.hot) {
    module.hot.accept(['./showcase'], () => {
      const newShowcase = require('./showcase').default
      Store.hotUpdate({ modules: { showcase: newShowcase } })
    })
    module.hot.accept(['./layoutDemo'], () => {
      const newLayoutDemo = require('./layoutDemo').default
      Store.hotUpdate({ modules: { layoutDemo: newLayoutDemo } })
    })
  }
github FantasticFiasco / searchlight / src / renderer / store / store.ts View on Github external
import Vue from 'vue';
import Vuex, { Store } from 'vuex';

import { isDev } from 'common';
import { ApplicationUpdatesModule } from './application-updates/application-updates-module';
import { DevicesModule } from './devices/devices-module';
import { HeartbeatsModule } from './heartbeats/heartbeats-module';
import { IRootState } from './i-root-state';

Vue.use(Vuex);

export const store = new Store({
    modules: {
        applicationUpdates: new ApplicationUpdatesModule(),
        devices: new DevicesModule(),
        heartbeats: new HeartbeatsModule(),
    },
    strict: isDev(),
});
github Meituan-Dianping / Zebra / zebra-admin-web / src / main / webapp / app / src / main.js View on Github external
Vue.use(VueRouter)
Vue.use(iView)
Vue.use(Vuex)
Vue.use(Util)
Vue.prototype.$echarts = echarts

Vue.prototype.makehl = function(str) {
    var value = hljs.highlightAuto(str);
  return value.value
}

const router = new VueRouter({
  routes: route
})

const store = new Vuex.Store({
  state:{
    init : false,
    currentEnv : null,
    envs : [],
    user:'',
    staredJdbcrefs:[],
    staredShards:[],
    staredJdbcrefDtos:[],
    staredShardDtos:[]
  },
  getters: {},
  mutations: {

  },
  actions: {}
})
github gitlabhq / gitlabhq / spec / frontend / ide / components / terminal_sync / terminal_sync_status_spec.js View on Github external
const createComponent = () => {
    store = new Vuex.Store({
      modules: {
        terminalSync: {
          namespaced: true,
          state: moduleState,
          mutations: {
            [START_LOADING]: (state) => {
              state.isLoading = true;
            },
          },
        },
      },
    });

    wrapper = shallowMount(TerminalSyncStatus, {
      localVue,
      store,
github gitlabhq / gitlabhq / spec / frontend / packages / details / components / npm_installation_spec.js View on Github external
function createComponent({ data = {} } = {}) {
    const store = new Vuex.Store({
      state: {
        packageEntity,
        nugetPath,
      },
      getters: {
        npmInstallationCommand,
        npmSetupCommand,
      },
    });

    wrapper = shallowMount(NpmInstallation, {
      localVue,
      store,
      data() {
        return data;
      },