Skip to content

Commit 8a09b7c

Browse files
committed
Helpers initialization order is set by decleration order
1 parent 56af670 commit 8a09b7c

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

packages/angular-meteor-data/modules/angular-meteor-reactive-context.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ angular.module('angular-meteor.reactive', ['angular-meteor.reactive-scope']).fac
2929

3030
_handleCursor(cursor, name) {
3131
if (angular.isUndefined(this.context[name])) {
32-
this._setValHelper(cursor.fetch(), name);
32+
this._setValHelper(name, cursor.fetch());
3333
}
3434
else {
3535
let diff = jsondiffpatch.diff(this.context[name], cursor.fetch());
@@ -66,7 +66,7 @@ angular.module('angular-meteor.reactive', ['angular-meteor.reactive-scope']).fac
6666

6767
_handleNonCursor(data, name) {
6868
if (angular.isUndefined(this.context[name])) {
69-
this._setValHelper(data, name);
69+
this._setValHelper(name, data);
7070
}
7171
else {
7272
if ((!_.isObject(data) && !_.isArray(data)) ||
@@ -82,24 +82,17 @@ angular.module('angular-meteor.reactive', ['angular-meteor.reactive-scope']).fac
8282
}
8383

8484
helpers(props) {
85-
let fns = {};
86-
let vals = {};
87-
8885
_.each(props, (v, k) => {
8986
if (_.isFunction(v))
90-
fns[k] = v;
87+
this._setFnHelper(k, v);
9188
else
92-
vals[k] = v;
89+
this._setValHelper(k, v);
9390
});
9491

95-
// note that variable helpers are set before function helpers
96-
_.each(vals, this._setValHelper.bind(this));
97-
_.each(fns, this._setFnHelper.bind(this));
98-
9992
return this;
10093
}
10194

102-
_setValHelper(v, k) {
95+
_setValHelper(k, v) {
10396
this.propertiesTrackerDeps[k] = new Tracker.Dependency();
10497
v = _.clone(v);
10598

@@ -118,7 +111,7 @@ angular.module('angular-meteor.reactive', ['angular-meteor.reactive-scope']).fac
118111
});
119112
}
120113

121-
_setFnHelper(fn, k) {
114+
_setFnHelper(k, fn) {
122115
this.stoppables.push(Tracker.autorun((comp) => {
123116
let data = fn.apply(this.context);
124117

0 commit comments

Comments
 (0)