Skip to content

Commit e1f6c14

Browse files
committed
Fixed option merging
1 parent 9299f98 commit e1f6c14

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ Vue.use(VueMeteorTracker);
2222

2323
*Note: if you are using the Meteor [akryum:vue](https://github.com/Akryum/meteor-vue-component/tree/master/packages/vue) package, you don't need to install the plugin.*
2424

25+
**⚠️ You may need to polyfill `Object.assign`.**
26+
2527
## Usage
2628

2729
In your Vue component, add a `meteor` object :

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-meteor-tracker",
3-
"version": "1.0.4",
3+
"version": "1.1.1",
44
"description": "Use Meteor Tracker reactivity inside Vue components",
55
"main": "index.js",
66
"scripts": {

src/vue-plugin.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function defaultSubscription(...args) {
88

99
export default {
1010
install(Vue, options) {
11-
11+
1212
const vueVersion = parseInt(Vue.version.charAt(0));
1313

1414
const { defineReactive } = Vue.util;
@@ -21,6 +21,25 @@ export default {
2121
for(const k in options) {
2222
Vue.config.meteor[k] = options[k];
2323
}
24+
25+
const merge = Vue.config.optionMergeStrategies.methods
26+
Vue.config.optionMergeStrategies.meteor = function (toVal, fromVal, vm) {
27+
if (!toVal) return fromVal
28+
if (!fromVal) return toVal
29+
30+
const toData = Object.assign({}, omit(toVal, [
31+
'subscribe',
32+
'data',
33+
]), toVal.data);
34+
const fromData = Object.assign({}, omit(fromVal, [
35+
'subscribe',
36+
'data',
37+
]), fromVal.data);
38+
39+
return Object.assign({
40+
subscribe: merge(toVal.subscribe, fromVal.subscribe),
41+
}, merge(toData, fromData))
42+
}
2443

2544
function prepare() {
2645
this._trackerHandles = [];

0 commit comments

Comments
 (0)