So long, Flow Controller

So long, Flow Controller

Presented at CocoaHeads Montreal on September 26th, 2019.

732de78cba7ebf62ccb9cf3ea08d618b?s=128

Olivier Collet

September 26, 2019
Tweet

Transcript

  1. 3.
  2. 4.

    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
  3. 9.

    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
  4. 13.

    Inherits from UIResponder with a reference to a root UIViewController

    Inherits from UIViewController UINavigationController, UITabBarController, or custom container view controller
  5. 14.

    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
  6. 16.

    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 { }
  7. 17.

    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? }
  8. 18.

    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