Skip to content

Commit 7615cdd

Browse files
committed
Document the extend method on makeServicePlugin
1 parent 4c8a627 commit 7615cdd

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

docs/3.0-major-release.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,33 @@ Version 3.0 of Feathers-Vuex is the Vue Composition API release! There were qui
1616

1717
And now it has become the best way to perform queries with Feathers-Vuex. To find out how to take advantage of the new functionality in your apps, read the [Feather-Vuex Composition API docs](./composition-api.md).
1818

19+
## New `extend` option for `makeServicePlugin` <Badge text="3.9.0+" />
20+
21+
The `makeServicePlugin` now supports an `extend` method that allows customizing the store and gives access to the actual Vuex `store` object, as shown in this example:
22+
23+
```js
24+
import { makeServicePlugin } from ‘feathers-vuex’
25+
import { feathersClient } from ‘./feathers-client.js’
26+
27+
class Todo { /* truncated */ }
28+
29+
export default makeServicePlugin({
30+
Model: Todo,
31+
service: feathersClient.service(‘todos’),
32+
extend({ store, module }) {
33+
// Listen to other parts of the store
34+
store.watch(/* truncated */)
35+
36+
return {
37+
state: {},
38+
getters: {},
39+
mutations: {},
40+
actions: {}
41+
}
42+
}
43+
})
44+
```
45+
1946
## Partial data on patch <Badge text="3.9.0+" />
2047
As of version 3.9.0, you can provide an object as `params.data`, and Feathers-Vuex will use `params.data` as the patch data. This change was made to the service-module, itself, so it will work for `patch` across all of feathers-vuex. Here's an example of patching with partial data:
2148

docs/service-plugin.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,36 @@ The `find` getter queries data from the local store using the same Feathers quer
730730

731731
## Customizing a Service's Default Store
732732

733-
As shown in the example below, the service module allows you to customize its store:
733+
### New `extend` option for `makeServicePlugin` <Badge text="3.14.0+" />
734+
735+
As of version `3.14.0`, the `makeServicePlugin` now supports an `extend` method that allows customizing the store and gives access to the actual Vuex `store` object, as shown in this example:
736+
737+
```js
738+
import { makeServicePlugin } from ‘feathers-vuex’
739+
import { feathersClient } from ‘./feathers-client.js’
740+
741+
class Todo { /* truncated */ }
742+
743+
export default makeServicePlugin({
744+
Model: Todo,
745+
service: feathersClient.service(‘todos’),
746+
extend({ store, module }) {
747+
// Listen to other parts of the store
748+
store.watch(/* truncated */)
749+
750+
return {
751+
state: {},
752+
getters: {},
753+
mutations: {},
754+
actions: {}
755+
}
756+
}
757+
})
758+
```
759+
760+
### Deprecated options for customizing the store
761+
762+
Before version `3.14.0`, you can customize the store using the options for `state`, `getters`, `mutations`, and `actions`, as shown below. This method is now deprecated and will be removed from Feathers-Vuex 4.0.
734763

735764
```js
736765
// src/store/services/users.js

0 commit comments

Comments
 (0)