Skip to content

Instantly share code, notes, and snippets.

@iamchiwon
Created September 17, 2018 17:02
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 iamchiwon/46b3732ec20fac568eb509adc2ec927a to your computer and use it in GitHub Desktop.
Save iamchiwon/46b3732ec20fac568eb509adc2ec927a to your computer and use it in GitHub Desktop.
Functions to Observable Wrapper
func reactivex<I, O>(_ f: @escaping (I) -> O) -> (I) -> Observable<O> {
return { input in
return Observable.create { emitter in
emitter.onNext(f(input))
emitter.onCompleted()
return Disposables.create()
}
}
}
func reactivex<I, O>(_ f: @escaping (I, @escaping (O) -> Void) -> Void) -> (I) -> Observable<O> {
return { i in
return Observable.create { emitter in
f(i, { o in
emitter.onNext(o)
emitter.onCompleted()
})
return Disposables.create()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment