0.1.0-alpha.4 • Published 3 years ago
@reactxjs/reactx v0.1.0-alpha.4
ReactX
Simplified ReactJS Store manager with persistent storage This is loosely based on VueX (VueJS Store manager)
How to setup local repo testing
- Clone the repo
- run npm install
- run npm start
- add
"@reactxjs/reactx": "file:path/to/reactx"
to your package.json
Install
npm install --save @reactxjs/reactx
Create Store
import ReactX from '@reactxjs/reactx';
import test from './modules/test';
export default new ReactX({
modules: [
test,
]
});
Create Store module
export default {
name: 'test',
persistent: true,
state: {
test: [],
},
getters: {
get: state => state.test
},
mutations: {
setup(state, data) {
state.test = data;
}
},
actions: {
setup({ commit }, data) {
commit('setup', data);
},
},
};
Bind your store to React instance
import React from 'react';
import store from './store';
React.$store = store;
Dispatch to store
React.$store.dispatch('test/setup', [1, 2, 3]);
Get from store
React.$store.getters('test/get')
0.1.0-alpha.4
3 years ago
0.1.0-alpha.3
3 years ago
0.1.0-alpha.2
3 years ago
0.1.0-alpha.1
3 years ago
0.1.0-alpha.0
3 years ago
1.0.0
3 years ago