Router contains a link to navigation controller which contains stacked 1,2,3 view controllers (from 1,2,3 modules). Now module 3 commands router navigationController.popToRoot and should call someFunc() from module1.
If it is usual project I call popToRoot, get the root view controller and call someFunc() directly. But how to do it with VIPER architecture correctly?
I'd suggest two ways:
1) Implement a Coordinator. Let the Coordinator know that there's a
navigationController, and make it accessible by everyRouter, presumably bidirectional. Then, Coordinator can call Module1's method when Module3 is done.2) Implement a Notification System. Just keep calling
popToRootin Module3'sRouter, and send a notification to theNotificationCenter. Since Module1 will still be alive (since they are stacked), it can act/react accordingly.I'd vote for the first option though, having a Coordinator in VIPER immensely (and subjectively) helps with the routing.