0.18.2 • Published 1 month ago

@thzero/library_client_vue3_store_vuex v0.18.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

GitHub package.json version David License: MIT

library_client_vue3_store_vuex

An opinionated library for vue3 with vuex store for the library_client_vue3.

Requirements

NodeJs

NodeJs version 18+

Installation

NPM

Store Setup

Store.js

Setup the 'store/store.js' as follows:

import Vue from 'vue';
import VuexPersist from 'vuex-persist';

import LibraryClientConstants from '@thzero/library_client_vue/constants';

import BaseStore from '@/library_vue/store';

class AppStore extends BaseStore {
	_init() {
		return {
			modules: {
			},
			state: {
				version: null
			},
			actions: {
				async getVersion({ commit }, correlationId) {
					const service = LibraryClientUtility.$injector.getService(LibraryClientConstants.InjectorKeys.SERVICE_VERSION);
					const version = await service.version(correlationId);
					this.$logger.debug('store', 'getVersion', 'version', version, correlationId);
					commit('setVersion', { correlationId : correlationId, version: version });
				},
				async initialize({ commit }, correlationId) {
          // TODO: Call any services that are required during initialization
				},
				async setSettings({ commit }, params) {
					commit('setSettings', params);
				}
			},
			getters: {
			},
			mutations: {
				setVersion(state, params) {
					this.$logger.debug('store', 'setVersion', 'version', params.version, params.correlationId);
					state.version = params.version;
				}
			},
			dispatcher: {
				async getVersion(correlationId) {
					await LibraryClientUtility.$store.dispatch('getVersion', correlationId);
				},
				async initialize(correlationId) {
					await LibraryClientUtility.$store.dispatch('initialize', correlationId);
				}
			}
		};
	}

	_initModules() {
    // Initialize any store modules
    // i.e. this._addModule('yourmodulename', yourmodule);
	}

	_initPluginPersist() {
		return new VuexPersist({
			storage: window.localStorage,
			reducer: state => ({
        // TODO: any reducers?
				version: state.version
			})
		});
	}
}

export default AppStore;
0.18.2

1 month ago

0.18.1

2 months ago

0.17.2

1 year ago

0.16.15

1 year ago

0.16.16

1 year ago

0.16.17

1 year ago

0.16.14

1 year ago

0.16.13

1 year ago

0.16.12

1 year ago

0.16.11

1 year ago

0.16.10

1 year ago

0.16.9

1 year ago