Last active
May 21, 2016 04:37
-
-
Save pangers/ae21683f5e9a8ab7ae91 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
_ = Observable.just("hello") | |
.map { | |
return $0.characters.count //On main thread | |
} | |
.map { | |
return $0 + 5 // On main thread | |
} | |
.map { | |
return $0 + 10 // On main thread | |
} | |
.subscribeNext { //Observable subscribed to on main thread | |
print($0) | |
} | |
//Main thread at point of observable creation | |
_ = Observable.just("hello") | |
.map { | |
return $0.characters.count //On user interactive dispatch queue | |
} | |
.map { | |
return $0 + 5 //On user interactive dispatch queue | |
} | |
.map { | |
return $0 + 10 //On user interactive dispatch queue | |
} | |
.subscribeOn(ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .UserInteractive)) // User Interactive dispatch queue passed to subscribe on operator | |
.subscribeNext { //Observable subscribed to on main thread | |
print($0) //Printed on user initiated dispatch queue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment