We will see binding of all classes.Let us bind for list view.
Here is a list of classes with whom we are going to interact.
AppDelegate – Standard UIApplicationMain default class.
AppDependencies – A class which has methods to bind all classes.
Root-wireframe - A class which has all possible kind of transition code. (like push, pop, present etc.) List-wireframe - A class knows how to show its UI and all possible forward flow.
And other all classes that we have seen previous are presenter, interactor, view controller and entity. Here is a step by step process to bind all the classes.
Step:1 class name: AppDelegate We create object of dependency class.Here is a list of classes with whom we are going to interact.
AppDelegate – Standard UIApplicationMain default class.
AppDependencies – A class which has methods to bind all classes.
Root-wireframe - A class which has all possible kind of transition code. (like push, pop, present etc.) List-wireframe - A class knows how to show its UI and all possible forward flow.
And other all classes that we have seen previous are presenter, interactor, view controller and entity. Here is a step by step process to bind all the classes.
let appDependencies = AppDependencies()
Step:2 class name: AppDelegate, With dependency class we call its method.
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let wireframe = appDependencies.configureDependencies()
return true
}
Step:3 class name: AppDependencies In dependency class we can put all shared instance object and other objects we put it in a method.
class AppDependencies {
let rootWireFrame = RootWireframe()
//this is the root object so we need to create here, others go to their own function
//return value could be replaced with wireframe object
func configureDependencies() -> listWireFrame {
let listWireframe = listWireFrame()
listWireframe.rootWireframe = rootWireFrame
return listWireframe
}
}
Step:4 class name: AppDependencies
func configureDependencies() -> listWireFrame {
let listWireframe = listWireFrame()
let Presenter = listPresenter()
listWireframe.rootWireframe = rootWireFrame
listWireframe.listPresenter = Presenter
return listWireframe
}
Step:5 class name: AppDependencies
func configureDependencies() -> listWireFrame {
let listWireframe = listWireFrame()
let Presenter = listPresenter()
let Interactor = listInteractor()
listWireframe.listPresenter = Presenter
Presenter.listInteractor = Interactor
return listWireframe
}
Step:6 AppDependencies
func configureDependencies() -> listWireFrame {
let listWireframe = listWireFrame()
let Presenter = listPresenter()
let Interactor = listInteractor()
listWireframe.listPresenter = Presenter
Presenter.listInteractor = Interactor
Interactor.output = Presenter
listWireframe.rootWireframe = rootWireFrame
return listWireframe
}
Step:7 class name: AppDelegate
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
let wireframe = appDependencies.configureDependencies()
wireframe.presentListInterfaceFromWindow(window: window!)
return true
}
class name: list-wireframe
func presentListInterfaceFromWindow(window: UIWindow) {
let viewController = listViewControllerFromStoryboard()
viewController.eventHandler = listPresenter
listVC = viewController
listPresenter!.userInterface = viewController
rootWireframe?.showRootViewController(viewController: viewController, inWindow: window)
}
Step:8 class name: list-wireframe
func presentListInterfaceFromWindow(window: UIWindow) {
let viewController = listViewControllerFromStoryboard()
viewController.eventHandler = listPresenter
listVC = viewController
listPresenter!.userInterface = viewController
rootWireframe?.showRootViewController(viewController: viewController, inWindow: window)
}
Here is a full flow of binding of all classes.
No comments:
Post a Comment
Please do not spam.