File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " mobx-route " : minor
3+ ---
4+
5+ added ` unmount() ` method call for ` RouteViewModel ` when route will be closed
Original file line number Diff line number Diff line change 1- import { computed } from 'mobx' ;
1+ import { computed , reaction , when } from 'mobx' ;
22import {
33 type AnyAbstractRouteEntity ,
44 type IQueryParams ,
@@ -28,7 +28,23 @@ export abstract class RouteViewModel<
2828 [ 'pathParams' , computed . struct ] ,
2929 [ 'query' , computed ] ,
3030 ] ,
31- this . vmConfig . observable . viewModelStores ,
31+ this . vmConfig . observable . viewModels ,
32+ ) ;
33+
34+ when (
35+ ( ) => this . isMounted ,
36+ ( ) => {
37+ reaction (
38+ ( ) => this . route . isOpened ,
39+ ( isOpened ) => {
40+ if ( ! isOpened && this . isMounted ) {
41+ this . unmount ( ) ;
42+ }
43+ } ,
44+ { fireImmediately : true , signal : this . unmountSignal } ,
45+ ) ;
46+ } ,
47+ { signal : this . unmountSignal } ,
3248 ) ;
3349 }
3450
You can’t perform that action at this time.
0 commit comments