File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,11 @@ onDestroyed: ->
101
101
102
102
But you do not have to! They will be stopped automatically anyway.
103
103
104
+ If you want to prevent automatically stopping the computed field, maybe
105
+ because you are not accessing its value inside an autorun, you can pass
106
+ a ` true ` value as a third argument to its constructor. But be sure to cleanup
107
+ the field once you do not need it anymore.
108
+
104
109
``` javascript
105
110
field .flush ()
106
111
```
Original file line number Diff line number Diff line change 1
1
class ComputedField
2
- constructor : (func , equalsFunc ) ->
2
+ constructor : (func , equalsFunc , dontStop ) ->
3
3
handle = null
4
4
lastValue = null
5
5
@@ -15,10 +15,11 @@ class ComputedField
15
15
else
16
16
lastValue .set value
17
17
18
- Tracker .afterFlush ->
19
- # If there are no dependents anymore, stop the autorun. We will run
20
- # it again in the getter's flush call if needed.
21
- getter .stop () unless lastValue .dep .hasDependents ()
18
+ unless dontStop
19
+ Tracker .afterFlush ->
20
+ # If there are no dependents anymore, stop the autorun. We will run
21
+ # it again in the getter's flush call if needed.
22
+ getter .stop () unless lastValue .dep .hasDependents ()
22
23
23
24
# If something stops our autorun from the outside, we want to know that and update internal state accordingly.
24
25
# This means that if computed field was created inside an autorun, and that autorun is invalided our autorun is
You can’t perform that action at this time.
0 commit comments