SwiftUI

  • Declaration

    Swift

    extension View
  • Retrieves a mapping of the application state from the environment and provides it to a property in a SwiftUI view. Use the connect(updateWhen:mapState:) method to first inject the state from a parent view.

    struct MyView : View {
    
      @MappedState var todoList: TodoList
    
    }
    
    See more

    Declaration

    Swift

    @propertyWrapper
    public struct MappedState<State> : DynamicProperty where State : Equatable
  • Injects a function as a property in a view to dispatch actions to the provided store.

    struct MyView : View {
    
      @MappedDispatch() var dispatch
    
      func handleClick() {
        dispatch(AppAction.doSomething())
      }
    
    }
    
    See more

    Declaration

    Swift

    @propertyWrapper
    public struct MappedDispatch : DynamicProperty
  • A view that connects to the application state.

    See more

    Declaration

    Swift

    public protocol ConnectableView : Connectable, View
  • Binds a state to a setter based action for use by controls that expect a two-way binding value such as TextFields. This is useful for simple actions that are expected to be dispatched many times a second. It should be avoided by any complicated or asynchronous actions.

    func map(state: AppState, binder: StateBinder) -> Props? {
      Props(
        todos: state.todos,
        orderBy: binder.bind(state.orderBy) { TodoListAction.setOrderBy($0) }
      )
    }
    
    See more

    Declaration

    Swift

    public struct ActionBinder
  • Binds a value with an action. Use the ActionBinder to create an action binding.

    See more

    Declaration

    Swift

    @propertyWrapper
    public struct ActionBinding<Value>
    extension ActionBinding: Equatable where Value: Equatable