Skip to content

Instantly share code, notes, and snippets.

@twittemb
Created March 19, 2020 20:51
Show Gist options
  • Save twittemb/11627c6d958eb1b40d4c7819ae28bff4 to your computer and use it in GitHub Desktop.
Save twittemb/11627c6d958eb1b40d4c7819ae28bff4 to your computer and use it in GitHub Desktop.
Button(action: {
self.uiSpin.emit(Event.startCounter)
}) {
Text("\(self.uiSpin.state.isCounterPaused ? "Start": "Stop")")
}
// A SwiftUISpin can also be used to produce SwiftUI bindings:
Toggle(isOn: self.uiSpin.binding(for: \.isPaused, event: .toggle) {
Text("toggle")
}
// \.isPaused is a keypath which designates a sub state of the state,
// and .toggle is the event to emit when the Toggle is changed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment