Skip to content

Commit ef0bb35

Browse files
Merge pull request #444 from fratzinger/patch-7
Update docs & removeTemps
2 parents c1a916c + fe144e1 commit ef0bb35

File tree

9 files changed

+218
-164
lines changed

9 files changed

+218
-164
lines changed

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
"search.exclude": {
88
"lib/**": true,
99
"**/node_modules": true,
10-
"**/bower_components": true
10+
"**/bower_components": true,
11+
"**/yarn.lock": true
1112
},
1213
"workbench.colorCustomizations": {
1314
"activityBar.background": "#2B3011",
1415
"titleBar.activeBackground": "#3C4418",
1516
"titleBar.activeForeground": "#FAFBF4"
1617
}
17-
}
18+
}

docs/3.0-major-release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ This behavior exactly matches the new `useFind` utility.
6565

6666
## Deprecations
6767

68-
### The `keepCopiesInStore` Option
68+
### The `keepCopiesInStore` Option<Badge text="deprecated" type="warning"/>
6969

7070
The `keepCopiesInStore` option is now deprecated. This was a part of the "clone and commit" API which basically disabled the reason for creating the "clone and commit" API in the first place.
7171

7272
If you're not familiar with the Feathers-Vuex "clone and commit" API, you can learn more about the [built-in data modeling](./model-classes.md) API and the section about [Working with Forms](./feathers-vuex-forms.md#the-clone-and-commit-pattern).
7373

7474
The `keepCopiesInStore` feature is set to be removed in Feathers-Vuex 4.0.
7575

76-
### Auth Plugin State: `user`
76+
### Auth Plugin State: `user`<Badge text="deprecated" type="warning"/>
7777

7878
As described, earlier on this page, since the Auth Plugin's `user` state is no longer reactive and has been replaced by a `user` getter that IS reactive, the `user` state will be removed in the Feathers-Vuex 4.0.

docs/common-patterns.md

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -174,42 +174,15 @@ in the above example of component code, the `upcomingAppointments` and `pastAppo
174174

175175
## Organizing the services in your project
176176

177-
You can use the file system to organize each service into its own module. This is especially useful in organizing larger-sized projects. Here's an example `store.js`. It uses Webpack's require.context feature save repetitive imports:
177+
You can use the file system to organize each service into its own module. This is especially useful in organizing larger-sized projects. Here's an example `store.js`. It uses Webpack's require.context feature save repetitive imports.
178178

179-
```js
180-
import Vue from 'vue'
181-
import Vuex from 'vuex'
182-
import { FeathersVuex } from '../feathers-client'
183-
import auth from './store.auth'
184-
185-
Vue.use(Vuex)
186-
Vue.use(FeathersVuex)
187-
188-
const requireModule = require.context(
189-
// The path where the service modules live
190-
'./services',
191-
// Whether to look in subfolders
192-
false,
193-
// Only include .js files (prevents duplicate imports`)
194-
/.js$/
195-
)
196-
const servicePlugins = requireModule
197-
.keys()
198-
.map(modulePath => requireModule(modulePath).default)
199-
200-
export default new Vuex.Store({
201-
state: {},
202-
mutations: {},
203-
actions: {},
204-
plugins: [...servicePlugins, auth]
205-
})
206-
```
179+
See it [here](/getting-started.html#auth-plugin)
207180

208181
With the `store.js` file in place, we can start adding services to the `services` folder.
209182

210-
- [Learn how to setup a Vuex plugin for a Feathers service.](/api-overview.html#service-plugins)
211-
- [Learn how to setup the feathers-client.js file](/api-overview.html)
212-
- [Learn how to setup the auth plugin](/api-overview.html#auth-plugin)
183+
- [Learn how to setup the feathers-client.js file](/getting-started.html#feathers-client-feathers-vuex)
184+
- [Learn how to setup a Vuex plugin for a Feathers service](/getting-started.html#service-plugins)
185+
- [Learn how to setup the auth plugin](/getting-started.html#auth-plugin)
213186

214187
## Actions return reactive store records
215188

@@ -482,7 +455,7 @@ todoCopy.commit()
482455
todoCopy2.commit()
483456
```
484457

485-
You can use the `keepCopiesInStore` option to make this service keep all of its copies in `state.copiesById`. Remember that to comply with Vuex `strict` mode (if that's a concern for you), you'll have to write custom mutations. If it's not a concern (maybe you're the sole developer or whatever reason), you could technically turn off `strict` mode, enable `keepCopiesInStore`, and modify them however you desire, ignoring custom mutations.
458+
You can use the `keepCopiesInStore`<Badge text="deprecated" type="warning"/> option to make this service keep all of its copies in `state.copiesById`. Remember that to comply with Vuex `strict` mode (if that's a concern for you), you'll have to write custom mutations. If it's not a concern (maybe you're the sole developer or whatever reason), you could technically turn off `strict` mode, enable `keepCopiesInStore`, and modify them however you desire, ignoring custom mutations.
486459

487460
```js
488461
import Vue from 'vue'

docs/getting-started.md

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,42 @@ The following default options are available for configuration:
269269

270270
```js
271271
const defaultOptions = {
272-
autoRemove: false, // Automatically remove records missing from responses (only use with feathers-rest)
273-
addOnUpsert: false, // Add new records pushed by 'updated/patched' socketio events into store, instead of discarding them
274-
enableEvents: true, // Listens to socket.io events when available. See the `handleEvents` API for more details
275-
idField: 'id', // The field in each record that will contain the id
276-
tempIdField: '__id',
277-
debug: false, // Set to true to enable logging messages.
278-
keepCopiesInStore: false, // Set to true to store cloned copies in the store instead of on the Model.
279-
nameStyle: 'short', // Determines the source of the module name. 'short', 'path', or 'explicit'
280-
paramsForServer: [], // Custom query operators that are ignored in the find getter, but will pass through to the server.
281-
preferUpdate: false, // When true, calling model.save() will do an update instead of a patch.
282-
replaceItems: false, // Instad of merging in changes in the store, replace the entire record.
272+
// configured globally
283273
serverAlias: 'api',
284-
skipRequestIfExists: false, // For get action, if the record already exists in store, skip the remote request
285-
whitelist: [] // Custom query operators that will be allowed in the find getter.
274+
keepCopiesInStore: false,
275+
paramsForServer: [],
276+
whitelist: []
277+
278+
// also configurable per service
279+
idField: 'id',
280+
tempIdField: '__id',
281+
debug: false,
282+
addOnUpsert: false,
283+
autoRemove: false,
284+
enableEvents: true,
285+
preferUpdate: false,
286+
replaceItems: false,
287+
skipRequestIfExists: false,
288+
nameStyle: 'short',
286289
}
287290
```
291+
- `serverAlias` - **Default:** `api` - Models are keyed by `serverAlias`. Access the `$FeathersVuex` Plugin and its models in your components by `this.$FeathersVuex.api.${Model}`
292+
- `keepCopiesInStore` - **Default:** `false` - Set to true to store cloned copies in the store instead of on the Model. <Badge text="deprecated" type="warning" />
293+
- `paramsForServer {Array}` - **Default:** `[]` - Custom query operators that are ignored in the find getter, but will pass through to the server.
294+
- `whitelist {Array}` - **Default:** `[]` - Custom query operators that will be allowed in the find getter.
295+
296+
- `idField {String}` - **Default:** `'id'` - The field in each record that will contain the id
297+
- `tempIdField {Boolean}` - **Default:** `'__id'` - The field in each temporary record that contains the id
298+
- `debug {Boolean}` - **Default:** `false` - Enable some logging for debugging
299+
- `addOnUpsert {Boolean}` - **Default:** `false` - If `true` add new records pushed by 'updated/patched' socketio events into store, instead of discarding them.
300+
- `autoRemove {Boolean}` - **Default:** `false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
301+
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off. See the services [handleEvents API](/service-plugin.html#configuration)
302+
- `preferUpdate {Boolean}` - **Default:** `false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
303+
- `replaceItems {Boolean}` - **Default:** `false` - If `true`, updates & patches replace the record in the store. Default is false, which merges in changes.
304+
- `skipRequestIfExists {Boolean}` - **Default:** `false` - For get action, if `true` the record already exists in store, skip the remote request.
305+
- `nameStyle {'short'|'path'}` - **Default:** `'short'` - Use the full service path as the Vuex module name, instead of just the last section.
306+
307+
Also see the [Configs per Service](/service-plugin.html#configuration)
288308

289309
### Note about feathers-reactive
290310

docs/model-classes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Feathers-Vuex 1.0 introduced some lightweight data modeling. Every service had
1010

1111
## Extending the BaseModel Class
1212

13-
While [setting up Feathers-Vuex](/api-overview.html#feathers-client-feathers-vuex), we exported the `BaseModel` class so that we could extend it. The below example shows how to import and extend the `BaseModel`. Each service must now have its own unique Model class.
13+
While [setting up Feathers-Vuex](/getting-started.html#feathers-client-feathers-vuex), we exported the `BaseModel` class so that we could extend it. The below example shows how to import and extend the `BaseModel`. Each service must now have its own unique Model class.
1414

1515
```js
1616
import feathersClient, { makeServicePlugin, BaseModel } from '../feathers-client'
@@ -360,7 +360,7 @@ console.log(todoCopy.description) // --> 'Do something else!'
360360

361361
There's another use case for using `.clone()`. Vuex has a `strict` mode that's really useful in development. It throws errors if any changes occur in the Vuex store `state` outside of mutations. Clone really comes in handy here, because you can make changes to the clone without having to write custom Vuex mutations. When you're finished making changes, call `.commit()` to update the store. This gives you `strict` mode compliance with little effort!
362362

363-
> Nonte: You could previously use the `keepCopiesInStore` option to keep copies in `state.copiesById`. In 2.0, this feature is deprecated and will be removed from the next release.
363+
> Note: You could previously use the `keepCopiesInStore`<Badge text="deprecated" type="warning"/> option to keep copies in `state.copiesById`. In 2.0, this feature is deprecated and will be removed from the next release.
364364
365365
### `instance.commit()`
366366

docs/nuxt.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The `models` and `$FeathersVuex` variables are the same object.
1616

1717
## Preventing Memory Leaks
1818

19-
The default settings of Feathers-Vuex include having realtime events enabled by default. This will result in increased memory usage over time on the SSR server. It can be turned off when you configure `feathers-vuex`. The example below has been modified from the example of [Setting up the Feathers Client & Feathers-Vuex](./api-overview.md#feathers-client-feathers-vuex). Look specifically at the `enableEvents` option.
19+
The default settings of Feathers-Vuex include having realtime events enabled by default. This will result in increased memory usage over time on the SSR server. It can be turned off when you configure `feathers-vuex`. The example below has been modified from the example of [Setting up the Feathers Client & Feathers-Vuex](./getting-started.html#feathers-client-feathers-vuex). Look specifically at the `enableEvents` option.
2020

2121
```js
2222
const { makeServicePlugin, makeAuthPlugin, BaseModel, models, FeathersVuex } = feathersVuex(

0 commit comments

Comments
 (0)