Skip to content

Instantly share code, notes, and snippets.

@twittemb
Created March 19, 2020 20:40
Show Gist options
  • Save twittemb/15f459e3564cc0a0125a8496d9fc4383 to your computer and use it in GitHub Desktop.
Save twittemb/15f459e3564cc0a0125a8496d9fc4383 to your computer and use it in GitHub Desktop.
func leftEffect(inputLevels: Levels) -> SignalProducer<Event, Never> {
// this is the stop condition to our Spin
guard inputLevels.left != inputLevels.right else { return .empty }
// this is the regulation for the left level
if inputLevels.left < inputLevels.right {
return SignalProducer(value: .increaseLeft)
} else {
return SignalProducer(value: .decreaseLeft)
}
}
func rightEffect(inputLevels: Levels) -> SignalProducer<Event, Never> {
// this is the stop condition to our Spin
guard inputLevels.left != inputLevels.right else { return .empty }
// this is the regulation for the right level
if inputLevels.right < inputLevels.left {
return SignalProducer(value: .increaseRight)
} else {
return SignalProducer(value: .decreaseRight)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment