Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Sources/Voiper/Embeddable.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// File.swift
//
//
// Created by Ekaterina Dvuzhilova on 2021-07-30.
//

import Foundation

public protocol Embeddable {
associatedtype ParentControllable
}
28 changes: 28 additions & 0 deletions Sources/Voiper/VOIPER.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,31 @@ extension Organiser where Presenter.Configuration == Void, Interactor.Configurat
router: Router.init(configuration: ()))
}
}

extension Organiser where Presenter: Embeddable, ViewController: ViewControllerType {
public static func createAsChildModule(presenterConfiguration: Presenter.Configuration, interactorConfiguration: Interactor.Configuration, routerConfiguration: Router.Configuration) -> (UIViewController, Presenter.ParentControllable) {
let childViewController = wireUpModule(presenter: Presenter(configuration: presenterConfiguration),
interactor: Interactor(configuration: interactorConfiguration),
router: Router(configuration: routerConfiguration))
guard let parentControllable = childViewController.presenter as? Presenter.ParentControllable else {
// TODO: it should be fixed, we should think about how to handle it in the best way
// make optional or throw error or smth else?
fatalError("")
}
return (childViewController, parentControllable)
}
}

extension Organiser where Presenter: Embeddable, ViewController: ViewControllerType, Presenter.Configuration == Void, Interactor.Configuration == Void, Router.Configuration == Void {
public static func createAsChildModule(presenterConfiguration: Presenter.Configuration, interactorConfiguration: Interactor.Configuration, routerConfiguration: Router.Configuration) -> (UIViewController, Presenter.ParentControllable) {
let childViewController = wireUpModule(presenter: Presenter(configuration: ()),
interactor: Interactor(configuration: ()),
router: Router(configuration: ()))
guard let parentControllable = childViewController.presenter as? Presenter.ParentControllable else {
// TODO: it should be fixed, we should think about how to handle it in the best way
// make optional or throw error or smth else?
fatalError("")
}
return (childViewController, parentControllable)
}
}