Skip to content

Commit 61636da

Browse files
committed
Use commit instead of dispatch
1 parent abb9518 commit 61636da

File tree

5 files changed

+50
-50
lines changed

5 files changed

+50
-50
lines changed

templates/vue/store/modules/foo/create.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,32 +43,32 @@ const getters = {
4343
};
4444

4545
const actions = {
46-
create({ dispatch }, values) {
47-
dispatch(loading(true));
46+
create({ commit }, values) {
47+
commit(loading(true));
4848

4949
return {{{ lc }}}Fetch('/{{{ name }}}', {method: 'POST', body: JSON.stringify(values)})
5050
.then(response => {
51-
dispatch(loading(false));
51+
commit(loading(false));
5252

5353
return response.json();
5454
})
5555
.then(data => {
56-
dispatch(success(data));
56+
commit(success(data));
5757
})
5858
.catch(e => {
59-
dispatch(loading(false));
59+
commit(loading(false));
6060

6161
if (e instanceof SubmissionError) {
62-
dispatch(violations(e.errors));
63-
dispatch(error(e.errors._error));
62+
commit(violations(e.errors));
63+
commit(error(e.errors._error));
6464
return;
6565
}
6666

67-
dispatch(error(e.message));
67+
commit(error(e.message));
6868
});
6969
},
70-
reset({ dispatch }) {
71-
dispatch(reset());
70+
reset({ commit }) {
71+
commit(reset());
7272
}
7373
};
7474

templates/vue/store/modules/foo/delete.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ const getters = {
3535
};
3636

3737
const actions = {
38-
delete({ dispatch }, item) {
39-
dispatch(loading(true));
38+
delete({ commit }, item) {
39+
commit(loading(true));
4040

4141
return {{{ lc }}}Fetch(item['@id'], {method: 'DELETE'})
4242
.then(() => {
43-
dispatch(loading(false));
44-
dispatch(success(item));
43+
commit(loading(false));
44+
commit(success(item));
4545
})
4646
.catch(e => {
47-
dispatch(loading(false));
48-
dispatch(error(e.message));
47+
commit(loading(false));
48+
commit(error(e.message));
4949
});
5050
},
51-
reset({ dispatch }) {
52-
dispatch(reset());
51+
reset({ commit }) {
52+
commit(reset());
5353
}
5454
};
5555

templates/vue/store/modules/foo/list.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ const getters = {
3636
};
3737

3838
const actions = {
39-
getItems({ dispatch }) {
40-
dispatch(loading(true));
39+
getItems({ commit }) {
40+
commit(loading(true));
4141

4242
{{{ lc }}}Fetch('/{{{ name }}}')
4343
.then(response => response.json())
4444
.then(data => {
45-
dispatch(loading(false));
46-
dispatch(success(data['{{{ hydraPrefix }}}member']));
47-
dispatch(view(data['{{{ hydraPrefix }}}view']));
45+
commit(loading(false));
46+
commit(success(data['{{{ hydraPrefix }}}member']));
47+
commit(view(data['{{{ hydraPrefix }}}view']));
4848
})
4949
.catch(e => {
50-
dispatch(loading(false));
51-
dispatch(error(e.message));
50+
commit(loading(false));
51+
commit(error(e.message));
5252
});
5353
}
5454
};

templates/vue/store/modules/foo/show.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,22 @@ const getters = {
3535
};
3636

3737
const actions = {
38-
retrieve({ dispatch }, id) {
39-
dispatch(loading(true));
38+
retrieve({ commit }, id) {
39+
commit(loading(true));
4040

4141
return {{{ lc }}}Fetch(id)
4242
.then(response => response.json())
4343
.then(data => {
44-
dispatch(loading(false));
45-
dispatch(retrieved(data));
44+
commit(loading(false));
45+
commit(retrieved(data));
4646
})
4747
.catch(e => {
48-
dispatch(loading(false));
49-
dispatch(error(e.message));
48+
commit(loading(false));
49+
commit(error(e.message));
5050
});
5151
},
52-
reset({ dispatch }) {
53-
dispatch(reset());
52+
reset({ commit }) {
53+
commit(reset());
5454
}
5555
};
5656

templates/vue/store/modules/foo/update.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,23 @@ const getters = {
6666
};
6767

6868
const actions = {
69-
retrieve({ dispatch }, id) {
70-
dispatch(retrieveLoading(true));
69+
retrieve({ commit }, id) {
70+
commit(retrieveLoading(true));
7171

7272
return {{{ lc }}}Fetch(id)
7373
.then(response => response.json())
7474
.then(data => {
75-
dispatch(retrieveLoading(false));
76-
dispatch(retrieveSuccess(data));
75+
commit(retrieveLoading(false));
76+
commit(retrieveSuccess(data));
7777
})
7878
.catch(e => {
79-
dispatch(retrieveLoading(false));
80-
dispatch(retrieveError(e.message));
79+
commit(retrieveLoading(false));
80+
commit(retrieveError(e.message));
8181
});
8282
},
83-
update({ dispatch, state }, { item, values }) {
84-
dispatch(updateError(null));
85-
dispatch(updateLoading(true));
83+
update({ commit, state }, { item, values }) {
84+
commit(updateError(null));
85+
commit(updateLoading(true));
8686

8787
return {{{ lc }}}Fetch(item['@id'], {
8888
method: 'PUT',
@@ -92,23 +92,23 @@ const actions = {
9292
)
9393
.then(response => response.json())
9494
.then(data => {
95-
dispatch(updateLoading(false));
96-
dispatch(updateSuccess(data));
95+
commit(updateLoading(false));
96+
commit(updateSuccess(data));
9797
})
9898
.catch(e => {
99-
dispatch(updateLoading(false));
99+
commit(updateLoading(false));
100100

101101
if (e instanceof SubmissionError) {
102-
dispatch(violations(e.errors));
103-
dispatch(updateError(e.errors._error));
102+
commit(violations(e.errors));
103+
commit(updateError(e.errors._error));
104104
return;
105105
}
106106

107-
dispatch(updateError(e.message));
107+
commit(updateError(e.message));
108108
});
109109
},
110-
reset({ dispatch }) {
111-
dispatch(reset());
110+
reset({ commit }) {
111+
commit(reset());
112112
}
113113
};
114114

0 commit comments

Comments
 (0)