Skip to content

Commit 8ada9cf

Browse files
committed
docs: change to $FeathersVuex object.
1 parent 3cc27b0 commit 8ada9cf

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/vue-plugin.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,18 @@ export default new Vuex.Store({
3838

3939
## Using the Vue Plugin
4040

41-
Once registered, you'll have access to the `this.$FeathersVuex` object, which contains references to the Model classes, keyed by name. The name of the model class is automatically inflected to singular, initial caps, based on the last section of the service path (split by `/`). Here are some examples of what this looks like:
41+
Once registered, you'll have access to the `this.$FeathersVuex` object. *In version 2.0, there is a breaking change to this object's structure.* Instead of directly containing references to the Model classes, the top level is keyed by `serverAlias`. Each `serverAlias` then contains the Models, keyed by name. This allows Feathers-Vuex 2.0 to support multiple FeathersJS servers in the same app. This new API means that the following change is required wherever you reference a Model class:
42+
43+
```js
44+
// 1.x way
45+
new this.$FeathersVuex.User({})
46+
47+
// 2.x way
48+
new this.$FeathersVuex.api.User({}) // Assuming default serverAlias of `api`.
49+
new this.$FeathersVuex.myApi.user({}) // If you customized the serverAlias to be `myApi`.
50+
```
51+
52+
The name of the model class is automatically inflected to singular, initial caps, based on the last section of the service path (split by `/`). Here are some examples of what this looks like:
4253

4354
| Service Name | Model Name in `$FeathersVuex` |
4455
| ------------------------- | ----------------------------- |
@@ -57,6 +68,18 @@ created () {
5768
}
5869
```
5970

71+
## New in 2.0
72+
73+
In Feathers-Vuex 2.0, the $FeathersVuex object is available as the 'models' export in the global package scope. This means you can do the following anywhere in your app:
74+
75+
```js
76+
import { models } from 'feathers-vuex'
77+
78+
const user = new models.api.User({
79+
80+
})
81+
```
82+
6083
## Included Components
6184

6285
When you register the Vue Plugin, a few components are automatically globally registered:

0 commit comments

Comments
 (0)