{"action":"opened","issue":{"url":"https://api.github.com/repos/quickbirdstudios/XCoordinator/issues/139","repository_url":"https://api.github.com/repos/quickbirdstudios/XCoordinator","labels_url":"https://api.github.com/repos/quickbirdstudios/XCoordinator/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/quickbirdstudios/XCoordinator/issues/139/comments","events_url":"https://api.github.com/repos/quickbirdstudios/XCoordinator/issues/139/events","html_url":"https://github.com/quickbirdstudios/XCoordinator/issues/139","id":516164195,"node_id":"MDU6SXNzdWU1MTYxNjQxOTU=","number":139,"title":"How to centralize a flow found in 2 coordinators?","user":{"login":"Kalzem","id":1152371,"node_id":"MDQ6VXNlcjExNTIzNzE=","avatar_url":"https://avatars2.githubusercontent.com/u/1152371?v=4","gravatar_id":"","url":"https://api.github.com/users/Kalzem","html_url":"https://github.com/Kalzem","followers_url":"https://api.github.com/users/Kalzem/followers","following_url":"https://api.github.com/users/Kalzem/following{/other_user}","gists_url":"https://api.github.com/users/Kalzem/gists{/gist_id}","starred_url":"https://api.github.com/users/Kalzem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kalzem/subscriptions","organizations_url":"https://api.github.com/users/Kalzem/orgs","repos_url":"https://api.github.com/users/Kalzem/repos","events_url":"https://api.github.com/users/Kalzem/events{/privacy}","received_events_url":"https://api.github.com/users/Kalzem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-11-01T14:57:14Z","updated_at":"2019-11-01T14:57:14Z","closed_at":null,"author_association":"NONE","body":"Alternative question: **How to implement a controller pushed by different coordinator/router?**\r\n\r\n## Context\r\n\r\nI have this flow:\r\n\r\n<img width=\"819\" alt=\"image\" src=\"https://user-images.githubusercontent.com/1152371/68032430-fae76d00-fcbd-11e9-9c65-61043fd615c3.png\">\r\n\r\nAnd this is my code:\r\n\r\n```swift\r\nclass TabCoordinator: TabBarCoordinator<TabRoute> {\r\n    private let playRouter: StrongRouter<PlayRoute>\r\n    private let learnRouter: StrongRouter<LearnRoute>\r\n    // ...\r\n}\r\n```\r\n\r\n\r\n```swift\r\nenum LearnRoute: Route {\r\n    case wordsList\r\n    case word(id: String)\r\n}\r\n\r\nclass LearnCoordinator: NavigationCoordinator<LearnRoute> {\r\n    override func prepareTransition(for route: LearnRoute) -> NavigationTransition {\r\n        switch route {\r\n        case .wordsList:\r\n            let vc = WordsListViewController(router: self.unownedRouter)\r\n            return .push(vc)\r\n        case let .word(id):\r\n            let vc = WordViewController(router: /*??*/, wordId: id)\r\n            return .push(vc)\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n```swift\r\nenum PlayRoute: Route {\r\n    case game\r\n    case word(id: String)\r\n}\r\n\r\nclass PlayCoordinator: NavigationCoordinator<PlayRoute> {\r\n    override func prepareTransition(for route: PlayRoute) -> NavigationTransition {\r\n        switch route {\r\n        case .game:\r\n            let vc = GameViewController(router: self.unownedRouter)\r\n            return .push(vc)\r\n        case let .word(id):\r\n            let vc = WordViewController(router: /*??*/, wordId: id)\r\n            return .push(vc)\r\n        }\r\n    }\r\n}\r\n```\r\n\r\n```swift\r\nclass WordViewController: UIViewController {\r\n    var router: UnownedRouter<??>\r\n\r\n    func didPressOnButton(id: String) {\r\n        self.router.trigger(.word(id: id))\r\n        // WordViewController can be pushed by either PlayCoord or LearnCoord\r\n        // so how to centralize the router object here?\r\n    }\r\n}\r\n```\r\n\r\n## Question\r\n\r\nMy question is related to how XCoordinator should be implemented when different paths of the application share identical subpaths.\r\n\r\nIn my case, for WordViewController, should I declare as many routers as WordViewController can handle? For example like this:\r\n\r\n```swift\r\nclass WordViewController: UIViewController {\r\n    var learnRouter: UnownedRouter<LearnRoute>?\r\n    var playRouter: UnownedRouter<PlayRoute>?\r\n\r\n    func didPressOnButton(id: String) {\r\n        self.learnRouter?.trigger(.word(id: id))\r\n        self.playRouter?.trigger(.word(id: id))\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"Kalzem"}}