Skip to content

Instantly share code, notes, and snippets.

@vincent-pradeilles
Last active August 16, 2017 13:21
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 vincent-pradeilles/217aa21db7e466073d3927b7f2d8245e to your computer and use it in GitHub Desktop.
Save vincent-pradeilles/217aa21db7e466073d3927b7f2d8245e to your computer and use it in GitHub Desktop.
func fromAsync<T>(_ asyncRequest: @escaping ( @escaping (T) -> Void) -> Void) -> Observable<T> {
return Observable.create({ (o) -> Disposable in
asyncRequest({ (result) in
o.onNext(result)
o.onCompleted()
})
return Disposables.create()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment