@@ -56,11 +56,37 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
5656 open override func viewDidLoad( ) {
5757 super. viewDidLoad ( )
5858
59+ viewModel. viewDidLoadSubject. onNext ( ( ) )
60+
5961 subviews ( ) . forEach { view. addSubview ( $0) }
6062 createConstraints ( )
6163 bind ( ) . forEach { $0. disposed ( by: disposeBag) }
6264 }
6365
66+ open override func viewWillAppear( _ animated: Bool ) {
67+ super. viewWillAppear ( animated)
68+
69+ viewModel. viewWillAppearSubject. onNext ( ( ) )
70+ }
71+
72+ open override func viewDidAppear( _ animated: Bool ) {
73+ super. viewDidAppear ( animated)
74+
75+ viewModel. viewDidAppearSubject. onNext ( ( ) )
76+ }
77+
78+ open override func viewWillDisappear( _ animated: Bool ) {
79+ super. viewWillDisappear ( animated)
80+
81+ viewModel. viewWillDisappearSubject. onNext ( ( ) )
82+ }
83+
84+ open override func viewDidDisappear( _ animated: Bool ) {
85+ super. viewDidDisappear ( animated)
86+
87+ viewModel. viewDidDisappearSubject. onNext ( ( ) )
88+ }
89+
6490 open func subviews( ) -> [ UIView ] {
6591 Log . debug ( " [WARNING] \( type ( of: self ) ) .subview() has not been overrided " )
6692 return [ ]
@@ -74,10 +100,9 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
74100 Log . debug ( " [WARNING] \( type ( of: self ) ) .bind() has not been overrided. " )
75101 return [ ]
76102 }
77-
103+
78104 /**
79105 Add a child view controller to the root view of the parent view controller.
80-
81106 @param childController: a child view controller.
82107 */
83108 override open func addChild( _ childController: UIViewController ) {
@@ -89,11 +114,11 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
89114 guard let childController = childController as? RxViewControllerProtocol else { return }
90115 viewModel. addChild ( childController. rxViewModel)
91116 }
92-
117+
93118 /**
94119 Add a child view controller to the a container view of the parent view controller.
95120 The edges of the child view controller is same as the container view by default.
96-
121+
97122 @param childController: a child view controller.
98123 @param containerView: a container view of childController.
99124 */
@@ -102,7 +127,7 @@ open class RxViewController<ViewModel: RxViewModel>: UIViewController, RxViewCon
102127 // Add child view controller to a container view of the parent view controller.
103128 containerView. addSubview ( childController. view)
104129 childController. didMove ( toParent: self )
105-
130+
106131 // Create constraints for the root view of the child view controller.
107132 childController. view. translatesAutoresizingMaskIntoConstraints = false
108133 childController. view. leftAnchor. constraint ( equalTo: containerView. leftAnchor) . isActive = true
0 commit comments