How to use vuex-smart-module - 5 common examples

To help you get started, we’ve selected a few vuex-smart-module 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 wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / src / store / index.ts View on Github external
import Vuex, { Store } from 'vuex';
import Application from '@/store/Application';
import { RootActions } from '@/store/actions';
import { RootGetters } from '@/store/getters';
import { RootMutations } from '@/store/mutations';
import { BaseState } from '@/store/state';
import { createStore as smartCreateStore, Module } from 'vuex-smart-module';
import ServiceContainer from '@/services/ServiceContainer';
import { NS_ENTITY, NS_STATEMENTS } from '@/store/namespaces';
import { entityModule } from './entity';
import { statementModule } from '@/store/statements';
import mutationsTrackerPlugin from '@/tracking/mutationsTrackerPlugin';

Vue.use( Vuex );

export const rootModule = new Module( {
	state: BaseState,
	getters: RootGetters,
	mutations: RootMutations,
	actions: RootActions,
	modules: {
		[ NS_ENTITY ]: entityModule,
		[ NS_STATEMENTS ]: statementModule,
	},
} );

export function createStore( services: ServiceContainer ): Store {

	const store = smartCreateStore( rootModule, {
		strict: process.env.NODE_ENV !== 'production',
		plugins: [ mutationsTrackerPlugin( services.get( 'tracker' ) ) ],
	} );
github wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / src / store / entity / index.ts View on Github external
import { EntityMutations } from '@/store/entity/mutations';
import { EntityActions } from '@/store/entity/actions';
import { Module } from 'vuex-smart-module';
import EntityId from '@/datamodel/EntityId';

export class EntityState {
	public id: EntityId = '';
	public baseRevision = 0;
}

export const entityModule = new Module( {
	state: EntityState,
	mutations: EntityMutations,
	actions: EntityActions,
} );
github wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / src / store / statements / index.ts View on Github external
import { StatementMap } from '@wmde/wikibase-datamodel-types';
import { Module } from 'vuex-smart-module';
import { StatementMutations } from '@/store/statements/mutations';
import { StatementActions } from '@/store/statements/actions';
import { StatementGetters } from '@/store/statements/getters';

export class StatementState {
	[ entityId: string ]: StatementMap;
}

export const statementModule = new Module( {
	state: StatementState,
	mutations: StatementMutations,
	actions: StatementActions,
	getters: StatementGetters,
} );
github wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / src / store / index.ts View on Github external
export function createStore( services: ServiceContainer ): Store {

	const store = smartCreateStore( rootModule, {
		strict: process.env.NODE_ENV !== 'production',
		plugins: [ mutationsTrackerPlugin( services.get( 'tracker' ) ) ],
	} );

	store.$services = services;
	return store;
}
github wikimedia / mediawiki-extensions-Wikibase / client / data-bridge / stories / useStore.js View on Github external
return () => {
		Vue.use( Vuex );
		rootModule.options.state = class {
			constructor() {
				Object.assign( this, state );
			}
		};
		const store = smartCreateStore( rootModule );
		return {
			store,
			template: '',
		};
	};
}

vuex-smart-module

Type safe Vuex module with powerful module features

MIT
Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis

Popular vuex-smart-module functions