Last active
May 21, 2016 04:40
-
-
Save pangers/f56d38162f4b5c9333ce 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
//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