Skip to content

Instantly share code, notes, and snippets.

View iampatbrown's full-sized avatar

Pat Brown iampatbrown

View GitHub Profile
@iampatbrown
iampatbrown / Reducer+BindingHelpers.swift
Created July 7, 2022 02:12
Helpers for creating reducers for BindableState
import ComposableArchitecture
import SwiftUI
extension Reducer {
/// Returns a reducer that applies ``BindingAction`` mutations to `LocalState` on `State`.
///
/// - Parameters:
/// - toLocalState: A key path that can get/set `LocalState` inside `State`.
/// - toLocalAction: A case path that can extract/embed `BindingAction` of `LocalState` from `Action`.
/// - Returns: A reducer that applies ``BindingAction`` mutations to `LocalState` on `State`.