File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,13 @@ export class MdSnackBarContainer extends BasePortalHost implements OnDestroy {
111111 }
112112
113113 if ( event . toState === 'visible' ) {
114+ // Note: we shouldn't use `this` inside the zone callback,
115+ // because it can cause a memory leak.
116+ const onEnter = this . onEnter ;
117+
114118 this . _ngZone . run ( ( ) => {
115- this . onEnter . next ( ) ;
116- this . onEnter . complete ( ) ;
119+ onEnter . next ( ) ;
120+ onEnter . complete ( ) ;
117121 } ) ;
118122 }
119123 }
@@ -152,9 +156,13 @@ export class MdSnackBarContainer extends BasePortalHost implements OnDestroy {
152156 * errors where we end up removing an element which is in the middle of an animation.
153157 */
154158 private _completeExit ( ) {
159+ // Note: we shouldn't use `this` inside the zone callback,
160+ // because it can cause a memory leak.
161+ const onExit = this . onExit ;
162+
155163 this . _ngZone . onMicrotaskEmpty . first ( ) . subscribe ( ( ) => {
156- this . onExit . next ( ) ;
157- this . onExit . complete ( ) ;
164+ onExit . next ( ) ;
165+ onExit . complete ( ) ;
158166 } ) ;
159167 }
160168}
You can’t perform that action at this time.
0 commit comments