This commit is contained in:
2024-05-30 22:54:58 -04:00
parent bd0f90894f
commit dac5d932dd
5 changed files with 238 additions and 52 deletions

View File

@@ -30,3 +30,20 @@ enum SetAction<State, Action, Value> {
}
}
@usableFromInline
struct SetAction2<State, Action, Value> {
let operation: @Sendable (inout State, Value) -> Void
init(_ operation: @escaping @Sendable (inout State, Value) -> Void) {
self.operation = operation
}
static func keyPath(
_ keyPath: WritableKeyPath<State, Value>
) -> Self {
.init({ state, value in
state[keyPath: keyPath] = value
})
}
}