Created
March 19, 2020 20:51
-
-
Save twittemb/11627c6d958eb1b40d4c7819ae28bff4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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