Skip to content

Commit c1149ef

Browse files
committed
Use commit instead of dispatch
1 parent 338d2dc commit c1149ef

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
@@ -41,32 +41,32 @@ const getters = {
4141
};
4242

4343
const actions = {
44-
create({ dispatch }, values) {
45-
dispatch(loading(true));
44+
create({ commit }, values) {
45+
commit(loading(true));
4646

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

5151
return response.json();
5252
})
5353
.then(data => {
54-
dispatch(success(data));
54+
commit(success(data));
5555
})
5656
.catch(e => {
57-
dispatch(loading(false));
57+
commit(loading(false));
5858

5959
if (e instanceof SubmissionError) {
60-
dispatch(violations(e.errors));
61-
dispatch(error(e.errors._error));
60+
commit(violations(e.errors));
61+
commit(error(e.errors._error));
6262
return;
6363
}
6464

65-
dispatch(error(e.message));
65+
commit(error(e.message));
6666
});
6767
},
68-
reset({ dispatch }) {
69-
dispatch(reset());
68+
reset({ commit }) {
69+
commit(reset());
7070
}
7171
};
7272

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)