git ssb

1+

Matt McKegg / mutant



Commit bf170bc7b3672405705146b57533b5850f041abc

computed: allow assignable "this" on lambda

Matt McKegg committed on 9/7/2016, 2:47:28 AM
Parent: 58609a3f2a099240f8ac9d9251ae95925dbbf203

Files changed

computed.jschanged
computed.jsView
@@ -33,8 +33,9 @@
3333 this.listeners = []
3434 this.observables = observables
3535 this.lambda = lambda
3636 this.opts = opts
37+ this.context = this.opts && this.opts.context || {}
3738 this.boundOnUpdate = this.onUpdate.bind(this)
3839 this.boundOnInnerUpdate = this.onInnerUpdate.bind(this)
3940 this.boundUpdateNow = this.updateNow.bind(this)
4041 }
@@ -104,9 +105,9 @@
104105 }
105106
106107 if (changed || !this.initialized) {
107108 this.initialized = true
108- var newComputedValue = this.lambda.apply(null, this.values)
109+ var newComputedValue = this.lambda.apply(this.context, this.values)
109110
110111 if (newComputedValue === computed.NO_CHANGE) {
111112 return false
112113 }

Built with git-ssb-web