Upgrade to Pro — share decks privately, control downloads, hide ads and more …

So long, Flow Controller

So long, Flow Controller

Presented at CocoaHeads Montreal on September 26th, 2019.

Olivier Collet

September 26, 2019
Tweet

More Decks by Olivier Collet

Other Decks in Programming

Transcript

  1. Flow Manager MVC Intent 1. Get Model 2. Setup Flow

    Dependent Elements 3. Presents MVC Intent 1. Get Model 2. Setup Flow Dependent Elements 3. Presents MVC Intent 1. Get Model 2. Setup Flow Dependent Elements 3. Presents MVC Intent 1. Get Model 2. Setup Flow Dependent Elements 3. Presents MVC Intent 1. Get Model 2. Setup Flow Dependent Elements 3. Presents
  2. Flow Controller 1. Keep the application’s state 2. Manage the

    logic between view controllers 3. Orchestrate the view controllers 4. Prevent view controller dependencies 5. Handle a portion of the application
  3. Inherits from UIResponder with a reference to a root UIViewController

    Inherits from UIViewController UINavigationController, UITabBarController, or custom container view controller
  4. View controllers report via delegate with lots of delegate protocols

    in a complex view controller hierarchy View controllers report via the responder chain low key introducing the Event and EventHandler protocols
  5. Event
 protocol • Similar to Error
 Can be used as

    an enum with associated values 
 or as a struct with properties • Passed along the responder chain
 
 protocol Event { }
  6. EventHandler
 protocol • Implement to receive Events • Specifies the

    event that can keep being propagated
 down the responder chain or no event to propagate protocol EventHandler: AnyObject { func handleEvent(_ event: Event) -> Event? }
  7. UIResponder
 extension • func postEvent(_ event: Event)
 propagates the event

    up the responder chain • var eventHandler: EventHandler?
 can be used to hook an object that is not part of the responder chain