`rx.viewDidLoad` not work.
PleaseDont opened this issue Β· 2 comments
PleaseDont commented
I used it with ReactorKit
followed your excellent App Drrrible
Here's my code:
final class HomeViewController: BaseViewController, StoryboardView {
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad normal π")
}
func bind(reactor: HomeViewReactor) {
self.rx.viewDidLoad
.subscribe(onNext: {
print("viewDidLoad Rx π")
})
.disposed(by: disposeBag)
self.rx.viewWillAppear.map { $0 }
.subscribe(onNext: {
print("viewWillAppear \($0)π")
})
.disposed(by: disposeBag)
}
}
Here's console outputs:
viewDidLoad normal π
viewWillAppear falseπ
The rx.viewDidLoad
did not trigger, did I miss something?
devxoul commented
With StoryboardView
the bind()
method gets called after the view is loaded. You have to use:
func bind(reactor: MyReactor) {
- self.rx.viewDidLoad
+ Observable.just(Void())
.map { Reactor.Action.foo }
.bind(to: reactor.action)
}
PleaseDont commented
@devxoul Thank you so much :-)