Commit 3a2cc56a1da6d73faff468fb282184e3a66fdc49
computed: add passthru
Matt McKegg committed on 5/9/2017, 6:40:36 PMParent: 4edad0777dfc5f6a55e3df0a63a61eaa98637cc5
Files changed
computed.js | changed |
computed.js | ||
---|---|---|
@@ -15,9 +15,9 @@ | ||
15 | 15 … | computed.NO_CHANGE = {} |
16 | 16 … | computed.extended = extendedComputed |
17 | 17 … | |
18 | 18 … | function computed (observables, lambda, opts) { |
19 | - // opts: nextTick, comparer, context | |
19 … | + // opts: nextTick, comparer, context, passthru | |
20 | 20 … | var instance = new ProtoComputed(observables, lambda, opts) |
21 | 21 … | return instance.MutantComputed.bind(instance) |
22 | 22 … | } |
23 | 23 … | |
@@ -39,8 +39,12 @@ | ||
39 | 39 … | this.observables = observables |
40 | 40 … | this.lambda = lambda |
41 | 41 … | this.opts = opts |
42 | 42 … | 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 … | + | |
43 | 47 … | this.context = opts && opts.context || {} |
44 | 48 … | this.boundOnUpdate = this.onUpdate.bind(this) |
45 | 49 … | this.boundUpdateNow = this.updateNow.bind(this) |
46 | 50 … | } |
@@ -135,9 +139,9 @@ | ||
135 | 139 … | } |
136 | 140 … | |
137 | 141 … | this.computedValue = newComputedValue |
138 | 142 … | |
139 | - if (isObservable(newComputedValue)) { | |
143 … | + if (isObservable(newComputedValue) && !this.passthru) { | |
140 | 144 … | // handle returning observable from computed |
141 | 145 … | this.outputValue = newComputedValue() |
142 | 146 … | this.inner = newComputedValue |
143 | 147 … | if (this.live) { |
Built with git-ssb-web