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 {
111
111
}
112
112
113
113
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
+
114
118
this . _ngZone . run ( ( ) => {
115
- this . onEnter . next ( ) ;
116
- this . onEnter . complete ( ) ;
119
+ onEnter . next ( ) ;
120
+ onEnter . complete ( ) ;
117
121
} ) ;
118
122
}
119
123
}
@@ -152,9 +156,13 @@ export class MdSnackBarContainer extends BasePortalHost implements OnDestroy {
152
156
* errors where we end up removing an element which is in the middle of an animation.
153
157
*/
154
158
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
+
155
163
this . _ngZone . onMicrotaskEmpty . first ( ) . subscribe ( ( ) => {
156
- this . onExit . next ( ) ;
157
- this . onExit . complete ( ) ;
164
+ onExit . next ( ) ;
165
+ onExit . complete ( ) ;
158
166
} ) ;
159
167
}
160
168
}
You can’t perform that action at this time.
0 commit comments