Skip to content

Instantly share code, notes, and snippets.

@LeonidKokhnovich
LeonidKokhnovich / ReThinkingCoordinators-CoordinatorProtocol.swift
Last active January 27, 2022 07:03
ReThinkingCoordinators-CoordinatorProtocol.swift
protocol Coordinator {
var children: [Coordinator] { get set }
func start()
}
@LeonidKokhnovich
LeonidKokhnovich / ReThinkingCoordinators-RefactorToCoordinators.swift
Last active January 27, 2022 07:05
ReThinkingCoordinators-RefactorToCoordinators
class NewsFeedCoordinator {
// #1
func start(presenter: UIViewController) {
let newsFeedVC = NewsfeedViewController()
newsFeedVC.onCreateNewPostOptionSelected = { [weak newsFeedVC] in
guard let newsFeedVC = newsFeedVC else { return }
// #2
self.showCreateNewPostFlow(presenter: newsFeedVC)
}
presenter.present(newsFeedVC, animated: true, completion: nil)
@LeonidKokhnovich
LeonidKokhnovich / ReThinkingCoordinators-ViewControllersOnly.swift
Last active January 27, 2022 07:05
ReThinkingCoordinators-ViewControllersOnly
class NewsfeedViewController: UIViewController {
// …
func onCreateNewPostOptionSelected() {
// #1
let createNewPostVC = CreateNewPostViewController()
self.present(createNewPostVC, animated: true, completion: nil)
}
// …
}
// …