When we have a pushed view controller, how is the best practice to intercept navigation back button so as to call interactor -> router ?
If what you're trying to do is detach the router for the RIB that is being popped, one option is the following.
In the view controller that is being popped:
//in view controller that is being popped
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
if isMovingFromParentViewController {
listener?.movingFromParent()
}
}
Then your listener can delegate to the parent interactor and router that has the child router attached and it can detach your router for the RIB that is being popped.
Most helpful comment
If what you're trying to do is detach the router for the RIB that is being popped, one option is the following.
In the view controller that is being popped:
Then your listener can delegate to the parent interactor and router that has the child router attached and it can detach your router for the RIB that is being popped.