-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Learning Topic: Coordinator Pattern #1
Comments
Andrey Panov CoordinatorAfter doing some reading I quite like the approach taken in these articles by Andrey Panov: He also describes this pattern in a way that it could be used in MVVM, MVC, VIPER, etc, by calling the VM, VC, IPV - "modules" Sample code here, it also has tests 🤘: Why should we use it?
He uses a similar protocol to the one mentioned above but simpler: protocol Coordinator: class {
func start()
func start(with option: DeepLinkOption?) // This is used for deep linking
} He has extracted the He has also moved the So this example's coordinator is composed of two protocols, Coordinator & CoordinatorOutput, to allow for optional results after a flow has finished. protocol CoordinatorOutput {
var finishFlow: (Item -> Void)? { get set }
} Terminologyusing "show" prefix in coordinator methods when moving to another module, e.g., func showItemList() using "run" prefix in coordinator methods when moving to another flow/coordinator, e.g., func runCreationFlow() SummaryThe architecture elements proposed here are:
I feel this approach has a lot of fo flexibility and looks easy to extend for other cases in navigation flow. I am going to start with this approach and feedback and issues. Pavle Pesic has blogged about using this pattern How to implement flow coordinator pattern |
iOS Academy CoordinatorVideo: Swift Coordinator Design Pattern (iOS, Xcode 12, 2021) - iOS Design PatternsProtocolprotocol Coordinator {
var navigationcontroller: UINavigationController? { get set }
funceventOccurred(with type: Event)
func start()
}
protocol Coordinating {
var coordinator: Coordinator? { get set }
}
enum Event {
case buttonTapped
} Summary
|
James Haville CoordinatorVideo: MVVM iOS App Part 4: View | Event Countdown AppSet of tutorials on creaditing MVVM architecture with Coordinator Protocolprotocol Coordinator {
var childCoordinators: [Coordinator] { get }
func start()
} Summary
|
Ray Wenderlich CoordinatorArticle: Coordinator PatternProtocolpublic protocol Coordinator: class {
var children: [Coordinator] { get set }
var router: Router { get }
func present(animated: Bool, onDismissed: (() -> Void)?)
func dismiss(animated: Bool)
func presentChild(_ child: Coordinator,
animated: Bool,
onDismissed: (() -> Void)?)
} When to use it?
Summary
|
Topic: Coordinator Pattern
Coordinator pattern created by Soroush Khanlou from a series of articles and a talk given at NSSpain
Example protocol for the most basic Coordinator:
This is a good starting point for the protocol but not every project uses this protocol. I will need to assess other example protocols to see why they have changed parts of this.
Why:
This pattern is to:
Here is a simple example,
with the coordinator pattern and delegation this can result in:
This is a much cleaner approach as we can reuse the
HomeViewController
in other places within our app or swap out its coordinator to change the navigation inhomeViewControllerDidPressButton
Notes:
This pattern has been around since 2015 so a lot has progressed since then, prepare to find it has evolved.
Some seem to use Delegates for events between Coordinator and ViewControllers others use Closures, need to see why this is the case?
Using closures with the coordinator pattern
Possibly use both?
Why do some of the examples use Factories?
Resources:
Articles:
https://www.raywenderlich.com/books/design-patterns-by-tutorials/v3.0/chapters/23-coordinator-pattern
https://medium.com/blacklane-engineering/coordinators-essential-tutorial-part-i-376c836e9ba7
https://medium.com/blacklane-engineering/coordinators-essential-tutorial-part-ii-b5ab3eb4a74
https://pavlepesic.medium.com/flow-coordination-pattern-5eb60cd220d5 - references Andrey's Coordinator and others
https://www.hackingwithswift.com/articles/71/how-to-use-the-coordinator-pattern-in-ios-apps
https://wojciechkulik.pl/ios/mvvm-coordinators-rxswift-and-sample-ios-application-with-authentication
https://mattwyskiel.com/posts/2016/07/20/protocol-oriented-app-coordinator-swift.html
https://medium.com/devexperts/real-world-example-of-using-coordinator-pattern-in-an-ios-app-d13df10496a5
https://benoitpasquier.com/coordinator-pattern-navigation-back-button-swift/
Videos:
Examples:
https://github.com/AndreyPanov/ApplicationCoordinator
https://github.com/daveneff/Coordinator
https://github.com/igorkulman/iOSSampleApp
https://github.com/wojciech-kulik/Swift-MVVMC-Demo
https://github.com/hanifsgy/Journal-MVVMCRxSwift
https://github.com/behrad-kzm/SpotifyExplorer
https://github.com/omerfarukozturk/MovieBox-iOS-MVVMC
https://github.com/sunshinejr/Kittygram
SwiftUI
https://github.com/rundfunk47/stinsen
https://github.com/SwiftUIX/Coordinator
The text was updated successfully, but these errors were encountered: