Commit bf170bc7b3672405705146b57533b5850f041abc
computed: allow assignable "this" on lambda
Matt McKegg committed on 9/7/2016, 2:47:28 AMParent: 58609a3f2a099240f8ac9d9251ae95925dbbf203
Files changed
computed.js | changed |
computed.js | ||
---|---|---|
@@ -33,8 +33,9 @@ | ||
33 | 33 | this.listeners = [] |
34 | 34 | this.observables = observables |
35 | 35 | this.lambda = lambda |
36 | 36 | this.opts = opts |
37 | + this.context = this.opts && this.opts.context || {} | |
37 | 38 | this.boundOnUpdate = this.onUpdate.bind(this) |
38 | 39 | this.boundOnInnerUpdate = this.onInnerUpdate.bind(this) |
39 | 40 | this.boundUpdateNow = this.updateNow.bind(this) |
40 | 41 | } |
@@ -104,9 +105,9 @@ | ||
104 | 105 | } |
105 | 106 | |
106 | 107 | if (changed || !this.initialized) { |
107 | 108 | this.initialized = true |
108 | - var newComputedValue = this.lambda.apply(null, this.values) | |
109 | + var newComputedValue = this.lambda.apply(this.context, this.values) | |
109 | 110 | |
110 | 111 | if (newComputedValue === computed.NO_CHANGE) { |
111 | 112 | return false |
112 | 113 | } |
Built with git-ssb-web