Created
May 19, 2016 06:55
-
-
Save syou007/b4870d2cd63fa6a6eade57ac21881143 to your computer and use it in GitHub Desktop.
Observableを順番に処理させるサンプル ref: http://qiita.com/syou007/items/44e5d4541b22f973d12b
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
let a:Observable<Int> = Observable.create { observable in | |
NSOperationQueue().addOperationWithBlock({ () -> Void in | |
sleep(5) | |
observable.onNext(1) | |
observable.onCompleted() | |
}) | |
return NopDisposable.instance | |
} | |
let b:Observable<Int> = Observable.create { observable in | |
NSOperationQueue().addOperationWithBlock({ () -> Void in | |
sleep(5) | |
observable.onNext(2) | |
observable.onCompleted() | |
}) | |
return NopDisposable.instance | |
} | |
let c:Observable<Int> = Observable.create { observable in | |
NSOperationQueue().addOperationWithBlock({ () -> Void in | |
sleep(5) | |
observable.onNext(3) | |
observable.onCompleted() | |
}) | |
return NopDisposable.instance | |
} | |
a.concat(b).concat(c).subscribeNext { (value) in | |
print(value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment