seneDelegate
초기 설정
private var launchRouter: LaunchRouting?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
self.window = window
let launchRouter = RootBuilder(dependency: AppComponent()).build()
self.launchRouter = launchRouter
launchRouter.launch(from: window)
}
}
build() 메서드에서 리턴타입을 LauchRouting 으로 수정
protocol RootBuildable: Buildable {
func build() -> LaunchRouting
}
final class RootBuilder: Builder<RootDependency>, RootBuildable {
override init(dependency: RootDependency) {
super.init(dependency: dependency)
}
func build() -> LaunchRouting {
let component = RootComponent(dependency: dependency)
let viewController = RootViewController()
let interactor = RootInteractor(presenter: viewController)
return RootRouter(interactor: interactor, viewController: viewController)
}
}
그러면 이제 RootRouter가 LaunchRouting을 채택하야 만족하니께 그렇게 수정
final class RootRouter: LaunchRouter<RootInteractable, RootViewControllable>, RootRouting {
// TODO: Constructor inject child builder protocols to allow building children.
override init(interactor: RootInteractable, viewController: RootViewControllable) {
super.init(interactor: interactor, viewController: viewController)
interactor.router = self
}
}
LoggedOutPresentableListener
<< viewContoller의 비지니스 로직을 Interactor로 옮기는 역할로 보이는데 여기에 login 함수를 추가해 준다.LoggedOutPresentableListener
를 채택한 LoggedOutInteractor
에 오류가 발생하게 되고 login 함수를 구현해서 에러를 없애주고 login 함수 내부에 비지니스 로직을 작성해 준다.LoggedOutViewContoller
에서 LoogedOutPresentableListner
를 타입으로 가지는 listener
를 활용해서 listener?.login() 함수를 호출해 준다.LoggetOutListener
<< 다른 RIB과 커뮤니케이션 하기 위한 프로토콜 여기서는 부모 RIB, 여기에 didLogin 함수를 선언LoggetOutInteractor
내부의 LoggedOutListener
프로토콜을 타입으로 가지는 listener
를 활용해서 호출 listerne?.didLogin()