Ribs: Intercepting back button

Created on 5 Jan 2018  路  1Comment  路  Source: uber/RIBs

When we have a pushed view controller, how is the best practice to intercept navigation back button so as to call interactor -> router ?

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:

//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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings