Skip to content

radianttap/Coordinator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

372 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


platforms: iOS|tvOS|watchOS|macOS|visionOS

Coordinator

Implementation of Coordinator design pattern. It is the application architecture pattern for iOS, carefully designed to fit into UIKit; so much it could easily become UICoordinator.

Since this is core architectural pattern, it’s not possible to explain its usage with one or two clever lines of code. Give it a day or two; analyze and play around. I’m pretty sure you’ll find it worthy of your time and future projects.

Installation

  • version 8.x is using Swift 6 language mode and has strict concurrency turned ON
  • version 7.x and up is made with Swift 5.5 concurrency in mind (async / await)
  • versions before that (6.x) use closures

Migrating to 8.1.0

Coordinator.init(rootViewController:) now takes a non-optional T instead of T?. The previous signature crashed on nil via preconditionFailure, so the only callers affected are those passing an explicit nil (which would have crashed anyway). Subclasses that construct their own root VC should build it before calling super.init(rootViewController:).

CoordinatingQueuedMessage is now @MainActor () -> Void. Closures passed to enqueueMessage(_:) already had to run on the main actor in practice; the annotation just makes the contract explicit.

NavigationCoordinator now offers async overloads of present(_:animated:) and dismiss(animated:) alongside the existing completion-based methods. They're purely additive — existing call sites keep working — but callers using structured concurrency can now write await coord.present(vc) instead of wrapping UIKit's completion API in a withCheckedContinuation themselves.

Just drag Coordinator folder into your project — it‘s only a handful of files.

Or add add this repo’s URL through Swift Package Manager.

Documentation

The why and how and...

License

MIT, as usual.

Give back

If you found this code useful, please consider buying me a coffee or two. ☕️😋

About

Implementation of Coordinators app design pattern.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages