b099l3 / DinkleBot-NativeiOS

A Destiny 2 companion app, that shows useful information for my needs. Also a testbed for me learning modern swift.
6 stars 1 forks source link

Learning Topic: Coordinator Pattern #4

Open b099l3 opened 3 years ago

b099l3 commented 3 years ago

The outcome from #1 Learning Topic: Coordinator Pattern

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

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?