WWDC19

Table of Contents

=================

Data Flow Through SwiftUI - Thursday

Session materials: https://developer.apple.com/videos/play/wwdc2019/226/

Tools for Data Flow

@State private var

@Binding Property Wrapper

  struct ContentView: View {
      @State private var foo: SomeType
      var body: some View {
         Button($foo) // Passing the binding here to the child view
        }
      }
  }

  struct Button: View {
    @Binding private var foo: SomeType
      var body: some View {
        // use the binding here without ownership
        Button(action: {
            withAnimation { self.foo.toggle()}
          })
      }
  }

Working with External Data

Combine Publisher

  someStack.onReceive(some.currentPublisher) { // Rx! }

BindableObject Protocol A.K.A RxSwift lol

  struct MyView: View {
    @ObjectBinding var model: MyModelObject
    ....
  }

  MyView(model: modelInstance)

  class MyModel: BindableObject {}

@EnvironmentObject

Source of Truth

Building Reusable Components

Using State Effectively