Skip to content

Instantly share code, notes, and snippets.

@Eluss
Created January 27, 2016 14:50
Show Gist options
  • Save Eluss/81de173bf0d6987656e9 to your computer and use it in GitHub Desktop.
Save Eluss/81de173bf0d6987656e9 to your computer and use it in GitHub Desktop.
// creating a signal
let (signal, sink) = Signal<Int, NoError>.pipe()
// function called when button is tapped
func buttonTapped(sender: UIButton) {
// sending random value down the stream
sendNext(sink, random() % 3)
}
// somewhere in the application
signal.observeNext {(value) -> () in
// print received value
print(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment