git ssb

1+

Matt McKegg / mutant



Commit 3a2cc56a1da6d73faff468fb282184e3a66fdc49

computed: add passthru

Matt McKegg committed on 5/9/2017, 6:40:36 PM
Parent: 4edad0777dfc5f6a55e3df0a63a61eaa98637cc5

Files changed

computed.jschanged
computed.jsView
@@ -15,9 +15,9 @@
1515 computed.NO_CHANGE = {}
1616 computed.extended = extendedComputed
1717
1818 function computed (observables, lambda, opts) {
19- // opts: nextTick, comparer, context
19 + // opts: nextTick, comparer, context, passthru
2020 var instance = new ProtoComputed(observables, lambda, opts)
2121 return instance.MutantComputed.bind(instance)
2222 }
2323
@@ -39,8 +39,12 @@
3939 this.observables = observables
4040 this.lambda = lambda
4141 this.opts = opts
4242 this.comparer = opts && opts.comparer || null
43 +
44 + // when true, don't expand nested observables, just treat as values
45 + this.passthru = opts && opts.passthru || null
46 +
4347 this.context = opts && opts.context || {}
4448 this.boundOnUpdate = this.onUpdate.bind(this)
4549 this.boundUpdateNow = this.updateNow.bind(this)
4650 }
@@ -135,9 +139,9 @@
135139 }
136140
137141 this.computedValue = newComputedValue
138142
139- if (isObservable(newComputedValue)) {
143 + if (isObservable(newComputedValue) && !this.passthru) {
140144 // handle returning observable from computed
141145 this.outputValue = newComputedValue()
142146 this.inner = newComputedValue
143147 if (this.live) {

Built with git-ssb-web