Skip to content
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 #4

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

b099l3
Copy link
Owner

@b099l3 b099l3 commented Jul 1, 2021

The outcome from #1 Learning Topic: Coordinator Pattern

Going with Andrey Panov Coordinator as it seems to offer the most flexibility and functionality:

  • I like the use of closures to communicate between coordinator and controller
  • I also like the use of factories to test
  • If this becomes a problem this article has some nice options (delegates)
    Using closures with the coordinator pattern

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

That allows to inject callbacks into a view controller rather than a specific coordinator. This has the effect of creating even more loose coupling than having a coordinator object or protocol, allowing us to replace coordinators with something else entirely if we wanted.

This technique of closure injection is nothing new – in fact, Apple even mentioned it in their WWDC 2016 presentation, Improving Existing Apps with Modern Best Practices. However, I think it has its limits: if you try to pass in more than a couple of closures it gets messy, and you should consider using a coordinator object or protocol instead.

Possibly use both?

Why do some of the examples use Factories?

@b099l3 b099l3 linked an issue Jul 9, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Learning Topic: Coordinator Pattern
1 participant