Skip to content

Commit a4a810e

Browse files
committed
2 parents 57606db + 2ea814d commit a4a810e

21 files changed

+21040
-106
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"lib/**": true,
99
"**/node_modules": true,
1010
"**/bower_components": true,
11-
"**/yarn.lock": true
11+
"**/yarn.lock": true,
12+
"**/package-lock.json": true
1213
},
1314
"workbench.colorCustomizations": {
1415
"activityBar.background": "#2B3011",

docs/getting-started.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,40 +274,54 @@ The following default options are available for configuration:
274274

275275
```js
276276
const defaultOptions = {
277-
// configured globally
277+
// only configured globally
278278
serverAlias: 'api',
279279
keepCopiesInStore: false,
280-
paramsForServer: [],
281-
whitelist: []
282280

283281
// also configurable per service
284282
idField: 'id',
285283
tempIdField: '__id',
284+
nameStyle: 'short',
285+
286286
debug: false,
287287
addOnUpsert: false,
288288
autoRemove: false,
289289
enableEvents: true,
290290
preferUpdate: false,
291291
replaceItems: false,
292292
skipRequestIfExists: false,
293-
nameStyle: 'short',
293+
294+
paramsForServer: [],
295+
whitelist: [],
296+
297+
handleEvents: {
298+
created: (item, { model, models }) => options.enableEvents,
299+
patched: (item, { model, models }) => options.enableEvents,
300+
updated: (item, { model, models }) => options.enableEvents,
301+
removed: (item, { model, models }) => options.enableEvents
302+
},
294303
}
295304
```
296305
- `serverAlias` - **Default:** `api` - Models are keyed by `serverAlias`. Access the `$FeathersVuex` Plugin and its models in your components by `this.$FeathersVuex.api.${Model}`
297306
- `keepCopiesInStore` - **Default:** `false` - Set to true to store cloned copies in the store instead of on the Model. <Badge text="deprecated" type="warning" />
298-
- `paramsForServer {Array}` - **Default:** `[]` - Custom query operators that are ignored in the find getter, but will pass through to the server.
299-
- `whitelist {Array}` - **Default:** `[]` - Custom query operators that will be allowed in the find getter.
300307

301308
- `idField {String}` - **Default:** `'id'` - The field in each record that will contain the id
302309
- `tempIdField {Boolean}` - **Default:** `'__id'` - The field in each temporary record that contains the id
310+
- `nameStyle {'short'|'path'}` - **Default:** `'short'` - Use the full service path as the Vuex module name, instead of just the last section.
303311
- `debug {Boolean}` - **Default:** `false` - Enable some logging for debugging
304312
- `addOnUpsert {Boolean}` - **Default:** `false` - If `true` add new records pushed by 'updated/patched' socketio events into store, instead of discarding them.
305313
- `autoRemove {Boolean}` - **Default:** `false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
306-
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off. See the services [handleEvents API](/service-plugin.html#configuration)
307314
- `preferUpdate {Boolean}` - **Default:** `false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
308315
- `replaceItems {Boolean}` - **Default:** `false` - If `true`, updates & patches replace the record in the store. Default is false, which merges in changes.
309316
- `skipRequestIfExists {Boolean}` - **Default:** `false` - For get action, if `true` the record already exists in store, skip the remote request.
310-
- `nameStyle {'short'|'path'}` - **Default:** `'short'` - Use the full service path as the Vuex module name, instead of just the last section.
317+
- `paramsForServer {Array}` - **Default:** `[]` - Custom query operators that are ignored in the find getter, but will pass through to the server.
318+
- `whitelist {Array}` - **Default:** `[]` - Custom query operators that will be allowed in the find getter.
319+
- `enableEvents {Boolean}` - **Default:** `true` - If `false` socket event listeners will be turned off. See the services
320+
- `handleEvents {Object}`: For this to work `enableEvents` must be `true`
321+
- `created {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to add to the store
322+
- `patched {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
323+
- `updated {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
324+
- `removed {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `removed` events, return true to remove from the store
311325

312326
Also see the [Configs per Service](/service-plugin.html#configuration)
313327

docs/service-plugin.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,36 @@ const servicePlugin = makeServicePlugin({
2626
Model,
2727
service: feathersClient.service(servicePath),
2828

29-
// optional and configurable by global config
29+
// optional and configurable also by global config
3030
idField: 'id',
3131
tempIdField: '__id',
32+
nameStyle: 'short',
3233
debug: false,
3334
addOnUpsert: false,
3435
autoRemove: false,
35-
enableEvents: true,
3636
preferUpdate: false,
3737
replaceItems: false,
3838
skipRequestIfExists: false,
39-
nameStyle: 'short',
4039

41-
// optional and only configurable per service
42-
servicePath: '',
43-
namespace: null,
44-
modelName: 'User',
40+
paramsForServer: [],
41+
whitelist: [],
4542

46-
instanceDefaults: () => ({}),
47-
setupInstance: instance => instance,
43+
enableEvents: true,
4844
handleEvents: {
4945
created: (item, { model, models }) => options.enableEvents,
5046
patched: (item, { model, models }) => options.enableEvents,
5147
updated: (item, { model, models }) => options.enableEvents,
5248
removed: (item, { model, models }) => options.enableEvents
5349
},
5450

51+
// optional and only configurable per service
52+
servicePath: '',
53+
namespace: null,
54+
modelName: 'User',
55+
56+
instanceDefaults: () => ({}),
57+
setupInstance: instance => instance,
58+
5559
state: {},
5660
getters: {},
5761
mutations: {},
@@ -64,14 +68,22 @@ The following options can also be configured in [Global Configuration](getting-s
6468

6569
- `idField {String}` - **Default:** `globalConfig: 'id'` - The field in each record that will contain the id
6670
- `tempIdField {Boolean}` - **Default:** `globalConfig: '__id'` - The field in each temporary record that contains the id
71+
- `nameStyle {'short'|'path'}` - **Default:** `globalConfig: 'short'` - Use the full service path as the Vuex module name, instead of just the last section.
6772
- `debug {Boolean}` - **Default:** `globalConfig: false` - Enable some logging for debugging
6873
- `addOnUpsert {Boolean}` - **Default:** `globalConfig: false` - If `true` add new records pushed by 'updated/patched' socketio events into store, instead of discarding them.
6974
- `autoRemove {Boolean}` - **Default:** `globalConfig: false` - If `true` automatically remove records missing from responses (only use with feathers-rest)
70-
- `enableEvents {Boolean}` - **Default:** `globalConfig: true` - If `false` socket event listeners will be turned off
7175
- `preferUpdate {Boolean}` - **Default:** `globalConfig: false` - If `true`, calling `model.save()` will do an `update` instead of a `patch`.
7276
- `replaceItems {Boolean}` - **Default:** `globalConfig: false` - If `true`, updates & patches replace the record in the store. Default is false, which merges in changes.
7377
- `skipRequestIfExists {Boolean}` - **Default:** `globalConfig: false` - For get action, if `true` the record already exists in store, skip the remote request.
74-
- `nameStyle {'short'|'path'}` - **Default:** `globalConfig: 'short'` - Use the full service path as the Vuex module name, instead of just the last section.
78+
- `paramsForServer {Array}` - Custom query operators that are ignored in the find getter, but will pass through to the server.
79+
- `whitelist {Array}` - Custom query operators that will be allowed in the find getter.
80+
- `enableEvents {Boolean}` - **Default:** `globalConfig: true` - If `false` socket event listeners will be turned off
81+
- `handleEvents {Object}`: For this to work `enableEvents` must be `true`
82+
- `created {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to add to the store
83+
- `patched {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
84+
- `updated {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
85+
- `removed {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `removed` events, return true to remove from the store
86+
-
7587

7688
The following options can only configured individually per service plugin
7789

@@ -80,11 +92,6 @@ The following options can only configured individually per service plugin
8092
- `modelName {String}` - **Default:** `${ServicePlugin.Model.modelName}`
8193
- `instanceDefaults {Function}` - **Default:** `() => ({})` - Override this method to provide default data for new instances. If using Model classes, specify this as a static class property.
8294
- `setupInstance {Function}` - **Default:** `instance => instance` - Override this method to setup data types or related data on an instance. If using Model classes, specify this as a static class property.
83-
- `handleEvents {Object}`: For this to work `enableEvents` must not be `false`
84-
- `created {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to add to the store
85-
- `patched {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
86-
- `updated {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `created` events, return true to update in the store
87-
- `removed {Function}` - **Default:** `(item, { model, models }) => options.enableEvents` - handle `removed` events, return true to remove from the store
8895

8996
- `state {Object}` - **Default:**: `null` - Pass custom `states` to the service plugin or modify existing ones
9097
- `getters {Object}` - **Default:** `null` - Pass custom `getters` to the service plugin or modify existing ones

0 commit comments

Comments
 (0)