Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Created September 9, 2019 21:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrandonw/73548617fc1ec060af5f3af8575722a2 to your computer and use it in GitHub Desktop.
Save mbrandonw/73548617fc1ec060af5f3af8575722a2 to your computer and use it in GitHub Desktop.
extension Store {
public func send<LocalValue>(
_ action: @escaping (LocalValue) -> Action,
binding keyPath: KeyPath<Value, LocalValue>
) -> Binding<LocalValue> {
Binding(
get: { self.value[keyPath: keyPath] },
set: { self.send(action($0)) }
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment