Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol _Reducer {
- associatedtype State
- associatedtype Action
- func reduce(state: inout State, action: Action)
- }
- protocol Reducer: _Reducer where State == Body.State, Action == Body.Action {
- associatedtype Body: Reducer
- var body: Body { get }
- }
- extension Reducer {
- func reduce(state: inout State, action: Action) {
- body.reduce(state: &state, action: action)
- }
- }
- struct ConcreteReducer<State, Action>: Reducer {
- let performReduce: (inout State, Action) -> Void
- var body: Self { self } // ???
- func reduce(state: inout State, action: Action) {
- performReduce(&state, action)
- }
- }
- // ERROR: 'Reducer' requires the types 'Action' and '
- // (some Reducer).Action' be equivalent
- struct EmptyRedcer<State, Action>: Reducer {
- var body: some Reducer {
- ConcreteReducer<State, Action> { state, action in
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement