Total Complexity | 5 |
Complexity/F | 5 |
Lines of Code | 48 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | import {matcher} from 'feathers-commons/lib/utils' |
||
2 | |||
3 | import Syncer from './syncer' |
||
4 | import syncerMixin from './mixin' |
||
5 | import {warn} from './utils' |
||
6 | |||
7 | const defaults = { |
||
8 | driver: Syncer, |
||
9 | idField: 'id', |
||
10 | matcher |
||
11 | } |
||
12 | |||
13 | export default { |
||
14 | /** |
||
15 | * Install to vue |
||
16 | * |
||
17 | * @function |
||
18 | * @param {Vue} Vue - Vue |
||
19 | * @param {Object} options - Options |
||
20 | * @param {Function} [options.driver] - Custom driver to use |
||
1 ignored issue
–
show
|
|||
21 | * @param {Object} [options.feathers] - Feathers client |
||
1 ignored issue
–
show
|
|||
22 | * @param {string} [options.idField] - Default ID field |
||
1 ignored issue
–
show
|
|||
23 | * @param {Function} [options.matcher] - Matcher creator |
||
1 ignored issue
–
show
|
|||
24 | */ |
||
25 | install: function (Vue, options = {}) { |
||
26 | const extend = Vue.util.extend |
||
27 | // Deprecation Warning: 0.3 |
||
28 | // Deprecate: 0.4 |
||
29 | /* istanbul ignore next */ |
||
30 | if (options.driverOptions && options.driverOptions.feathers) { |
||
31 | if (process.env.NODE_ENV !== 'production') { |
||
32 | warn('Deprecation warning: driverOptions.feathers to be deprecated in favor of just feathers') |
||
33 | } |
||
34 | options.feathers = options.driverOptions.feathers |
||
35 | } |
||
36 | // Vue 2.0 has util.toObject, but 1.0 doesn't |
||
37 | options = extend(extend({}, defaults), options) |
||
38 | |||
39 | if (!('feathers' in options)) { |
||
40 | throw new Error('No feathers instance set in options') |
||
41 | } |
||
42 | |||
43 | Vue.$syncer = options |
||
44 | Vue.mixin(syncerMixin(Vue)) |
||
45 | // Mixin handling |
||
46 | Vue.config.optionMergeStrategies.sync = Vue.config.optionMergeStrategies.props |
||
47 | } |
||
48 | } |
||
49 |