Skip to content

Instantly share code, notes, and snippets.

@syou007
Created May 19, 2016 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syou007/b4870d2cd63fa6a6eade57ac21881143 to your computer and use it in GitHub Desktop.
Save syou007/b4870d2cd63fa6a6eade57ac21881143 to your computer and use it in GitHub Desktop.
Observableを順番に処理させるサンプル ref: http://qiita.com/syou007/items/44e5d4541b22f973d12b
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