File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,12 @@ angular.module(name, [
131131 ! this . $$phase &&
132132 ! this . $root . $$phase ;
133133
134- if ( isDigestable ) this . $digest ( ) ;
134+ if ( isDigestable ) {
135+ // If a digest cycle in one autorun triggers another autorun,
136+ // we want to run this second autorun in a non-reactive manner.
137+ // thus preventing inner autoruns from being dependent on their parents.
138+ Tracker . nonreactive ( ( ) => this . $digest ( ) ) ;
139+ }
135140 } ;
136141
137142 // Creates a promise only that the digestion cycle will be called at its fulfillment
Original file line number Diff line number Diff line change @@ -90,6 +90,20 @@ describe('angular-meteor.core', function() {
9090
9191 expect ( stop . calledOnce ) . to . be . true ;
9292 } ) ;
93+
94+ it ( 'should run digest in a non-reactive manner, so autoruns triggered by the digest are not dependent on other autoruns' , function ( ) {
95+ scope . $watch ( 'foo' , function ( val ) {
96+ if ( val ) {
97+ var computation = scope . autorun ( angular . noop ) ;
98+ expect ( computation . _parent ) . to . be . null ;
99+ }
100+ } ) ;
101+
102+ scope . autorun ( function ( ) {
103+ scope . foo = 'baz' ;
104+ } ) ;
105+
106+ } ) ;
93107 } ) ;
94108
95109 describe ( 'subscribe()' , function ( ) {
You can’t perform that action at this time.
0 commit comments