@@ -8,8 +8,10 @@ import { Tracker } from 'meteor/tracker';
8
8
import { current_component , schedule_update , dirty_components } from 'svelte/internal' ;
9
9
10
10
11
- _autorun = Tracker . autorun ;
12
- Tracker . autorun = function autorun ( f , options ) {
11
+ const _autorun = Tracker . autorun ;
12
+ const _nonreactive = Tracker . nonreactive ;
13
+
14
+ function svelteAwareAutorun ( f , options ) {
13
15
const component = current_component ;
14
16
const computation = _autorun . apply ( this , arguments ) ;
15
17
if ( component ) {
@@ -18,6 +20,24 @@ Tracker.autorun = function autorun(f, options) {
18
20
_autoStopComputation ( computation , component ) ;
19
21
}
20
22
return computation ;
23
+ }
24
+
25
+ Tracker . autorun = svelteAwareAutorun ;
26
+
27
+ Tracker . nonreactive = function nonreactive ( f ) {
28
+ if ( current_component ) {
29
+ // A Tracker.autorun inside a Tracker.nonreactive should behave normally,
30
+ // without the special Svelte stuff.
31
+ const prevAutorun = Tracker . autorun ;
32
+ Tracker . autorun = _autorun ;
33
+ try {
34
+ return _nonreactive . apply ( this , arguments ) ;
35
+ } finally {
36
+ Tracker . autorun = prevAutorun ;
37
+ }
38
+ } else {
39
+ return _nonreactive . apply ( this , arguments ) ;
40
+ }
21
41
} ;
22
42
23
43
function _autoStopComputation ( computation , component ) {
0 commit comments