Skip to content

Commit ed92300

Browse files
committed
Support multiple vuex stores
1 parent 0ea7705 commit ed92300

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,8 @@ export default renderVue('Header', Header)
3030

3131
```js
3232
import { renderVuex, Vue } from 'hypernova-vue'
33-
import store from './store'
33+
import createStore from './store'
3434
import HeaderComponent from './components/HeaderComponent.vue'
3535

36-
const Header = Vue.extend({
37-
...HeaderComponent,
38-
store
39-
})
40-
41-
export default renderVuex('Header', Header)
36+
export default renderVuex('Header', HeaderComponent, createStore)
4237
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "hypernova-vue",
3-
"version": "1.1.0",
3+
"version": "2.0.0",
44
"description": "Vue bindings for Hypernova",
55
"main": "lib/index.js",
66
"author": "Felipe Guizar Diaz <felipegaiacharly@gmail.com>",

src/index.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,16 @@ export const renderVue = (name, Component) => hypernova({
3838
});
3939

4040

41-
export const renderVuex = (name, Component) => hypernova({
41+
export const renderVuex = (name, ComponentDefinition, createStore) => hypernova({
4242
server() {
4343
return async (propsData) => {
44+
const store = createStore();
45+
46+
const Component = Vue.extend({
47+
...ComponentDefinition,
48+
store,
49+
});
50+
4451
const vm = new Component({
4552
propsData,
4653
});
@@ -59,6 +66,13 @@ export const renderVuex = (name, Component) => hypernova({
5966
payloads.forEach((payload) => {
6067
const { node, data } = payload;
6168
const { propsData, state } = data;
69+
const store = createStore();
70+
71+
const Component = Vue.extend({
72+
...ComponentDefinition,
73+
store,
74+
});
75+
6276
const vm = new Component({
6377
propsData,
6478
});
@@ -69,6 +83,6 @@ export const renderVuex = (name, Component) => hypernova({
6983
});
7084
}
7185

72-
return Component;
86+
return ComponentDefinition;
7387
},
7488
});

0 commit comments

Comments
 (0)