Created
September 17, 2018 17:02
-
-
Save iamchiwon/46b3732ec20fac568eb509adc2ec927a to your computer and use it in GitHub Desktop.
Functions to Observable Wrapper
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
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