@@ -642,39 +642,54 @@ The `find` getter queries data from the local store using the same Feathers quer
642
642
As shown in the example below, the service module allows you to customize its store:
643
643
644
644
``` js
645
- const store = new Vuex.Store ({
646
- plugins: [
647
- // Add custom state, getters, mutations, or actions, if needed
648
- service (' things' , {
649
- state: {
650
- test: true
651
- },
652
- getters: {
653
- getSomeData () {
654
- return ' some data'
655
- }
656
- },
657
- mutations: {
658
- setTest (state , val ) {
659
- state .test = val;
660
- },
661
- },
662
- actions: {
663
- // Overwriting the built-in `afterFind` action.
664
- afterFind ({ commit, dispatch, getters, state }, response ) {
665
- // Do something with the response.
666
- // Keep in mind that the data is already in the store.
667
- },
668
- asyncStuff ({ state, getters, commit, dispatch }, args ) {
669
- commit (' setTestToTrue' )
670
- return new Promise.resolve (" " )
671
- }
672
- }
673
- })
674
- ]
645
+ // src/store/services/users.js
646
+ import feathersClient , { makeServicePlugin , BaseModel } from ' ../../feathers-client'
647
+
648
+ class Asset extends BaseModel {
649
+ constructor (data , options ) {
650
+ super (data, options)
651
+ }
652
+ // Required for $FeathersVuex plugin to work after production transpile.
653
+ static modelName = ' Asset'
654
+ // Define default properties here
655
+ static instanceDefaults () {
656
+ return {
657
+ email: ' ' ,
658
+ password: ' '
659
+ }
660
+ }
661
+ }
662
+
663
+ const servicePath = ' assets'
664
+ const servicePlugin = makeServicePlugin ({
665
+ Model: Asset,
666
+ service: feathersClient .service (servicePath),
667
+ servicePath,
668
+ state: {
669
+ test: true
670
+ },
671
+ getters: {
672
+ getSomeData () {
673
+ return ' some data'
674
+ }
675
+ },
676
+ mutations: {
677
+ setTest (state , val ) {
678
+ state .test = val;
679
+ },
680
+ },
681
+ actions: {
682
+ // Overwriting the built-in `afterFind` action.
683
+ afterFind ({ commit, dispatch, getters, state }, response ) {
684
+ // Do something with the response.
685
+ // Keep in mind that the data is already in the store.
686
+ },
687
+ asyncStuff ({ state, getters, commit, dispatch }, args ) {
688
+ commit (' setTestToTrue' )
689
+ return new Promise.resolve (" " )
690
+ }
691
+ }
675
692
})
676
693
677
- assert (store .getters [' todos/oneTwoThree' ] === 123 , ' the custom getter was available' )
678
- store .dispatch (' todos/trigger' )
679
- assert (store .state .todos .isTrue === true , ' the custom action was run' )
694
+ export default servicePlugin
680
695
```
0 commit comments