Skip to content

Commit 1947c81

Browse files
committed
docs: update example for accessing store from hooks
1 parent 8f0e2ce commit 1947c81

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

docs/common-patterns.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,27 @@ Because the service's Model [is available](./service-plugin.html#The-FeathersCli
3535
As an example, this `speeding-tickets` service has a `summary` attribute that comes back in the response. We can
3636

3737
```js
38-
import feathersVuex from 'feathers-vuex'
39-
import feathersClient from '../../feathers-client'
40-
41-
const { service } = feathersVuex(feathersClient, { idField: '_id' })
38+
import { makeServicePlugin, BaseModel } from '../feathers-client'
4239

43-
const servicePath = 'speeding-tickets'
44-
const servicePlugin = service(servicePath, {
45-
instanceDefaults: {
46-
vin: '',
47-
plateState: ''
48-
},
49-
mutations: {
50-
handleSummaryData (state, summaryData) {
51-
state.mostRecentSummary = summaryData
40+
class SpeedingTicket extends BaseModel {
41+
constructor(data, options) {
42+
super(data, options)
43+
}
44+
// Required for $FeathersVuex plugin to work after production transpile.
45+
static modelName = 'SpeedingTicket'
46+
// Define default properties here
47+
static instanceDefaults() {
48+
return {
49+
email: '',
50+
password: ''
5251
}
5352
}
53+
}
54+
const servicePath = 'speeding-tickets'
55+
const servicePlugin = makeServicePlugin({
56+
Model: SpeedingTicket,
57+
service: feathersClient.service(servicePath),
58+
servicePath
5459
})
5560

5661
feathersClient.service(servicePath)

0 commit comments

Comments
 (0)