Skip to content

Instantly share code, notes, and snippets.

@pangers
Last active May 21, 2016 04:40
Show Gist options
  • Save pangers/f56d38162f4b5c9333ce to your computer and use it in GitHub Desktop.
Save pangers/f56d38162f4b5c9333ce to your computer and use it in GitHub Desktop.
//Main thread at point of observable creation
_ = Observable.just("hello")
.map {
return $0.characters.count //On main thread
}
.map {
return $0 + 5 //On main thread
}
.observeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .UserInteractive)) // User Interactive dispatch queue passed to observe on operator
.map {
return $0 + 10 //On user interactive dispatch queue
}
.subscribeNext { //Observable subscribed to on main thread
print($0) //Printed on user interactive dispatch queue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment