You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/common-patterns.md
+33-80Lines changed: 33 additions & 80 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -88,17 +88,27 @@ Depending on what you need to do, you may be able to solve this by [accessing th
88
88
If you need the response data to already be in the store, you can use the [`afterFind` action](./service-plugin.html#afterFind-response). Here's what this looks like:
89
89
90
90
```js
91
-
importfeathersVuexfrom'feathers-vuex'
92
-
importfeathersClientfrom'../../feathers-client'
93
-
94
-
const { service } =feathersVuex(feathersClient, { idField:'_id' })
Using Live Queries will greatly simplify app development. The `find` getter enables this feature. Here's how you might setup a component to take advantage of them. For the below example, let's create two live-query lists using two getters.
128
+
Using Live Queries will greatly simplify app development. The`find` getter enables thisfeature. Here is how you might setup a component to take advantage ofthem. The next example shows how to setup two live-query lists using two getters.
120
129
121
130
```js
122
131
import { mapState, mapGetters, mapActions } from 'vuex'
@@ -162,93 +171,37 @@ You can use the file system to organize each service into its own module. This i
// Use the spread operator to register all of the imported plugins
190
-
...servicePlugins,
191
-
192
-
auth({ userService:'users' })
193
-
]
195
+
actions: {},
196
+
plugins: [...servicePlugins, auth]
194
197
})
195
198
```
196
199
197
-
With the `store.js` file in place, we can start adding services to the `services` folder. Here's an example user service. Notice that this format is a clean way to use hooks, as well.
200
+
With the `store.js` file in place, we can start adding services to the `services` folder.
198
201
199
-
```js
200
-
importfeathersVuexfrom'feathers-vuex'
201
-
importfeathersClientfrom'../../feathers-client'
202
-
203
-
const { service } =feathersVuex(feathersClient, { idField:'_id' })
204
-
205
-
constservicePath='users'
206
-
constservicePlugin=service(servicePath, {
207
-
instanceDefaults: {
208
-
email:'',
209
-
password:'',
210
-
roles: [],
211
-
firstName:'',
212
-
lastName:'',
213
-
getfullName () {
214
-
return`${this.firstName}${this.lastName}`
215
-
}
216
-
}
217
-
})
218
-
219
-
feathersClient.service(servicePath)
220
-
.hooks({
221
-
before: {
222
-
all: [],
223
-
find: [],
224
-
get: [],
225
-
create: [],
226
-
update: [],
227
-
patch: [],
228
-
remove: []
229
-
},
230
-
after: {
231
-
all: [],
232
-
find: [],
233
-
get: [],
234
-
create: [],
235
-
update: [],
236
-
patch: [],
237
-
remove: []
238
-
},
239
-
error: {
240
-
all: [],
241
-
find: [],
242
-
get: [],
243
-
create: [],
244
-
update: [],
245
-
patch: [],
246
-
remove: []
247
-
}
248
-
})
249
-
250
-
exportdefaultservicePlugin
251
-
```
202
+
- [Learn how to setup a Vuex plugin for a Feathers service.](/api-overview.html#service-plugins)
203
+
- [Learn how to setup the feathers-client.js file](/api-overview.html)
204
+
- [Learn how to setup the auth plugin](/api-overview.html#auth-plugin)
0 commit comments