pakoito
02/26/2020, 1:26 PMfx
block with a single line !
is the same as just pulling the thing you’re binding outsideGopal S Akshintala
02/26/2020, 1:28 PMeffect { libDBClient.get().k().suspended() }
in all my TCs, is there any way to abstract it out in common place, or is it inevitable?pakoito
02/26/2020, 1:29 PMGopal S Akshintala
02/26/2020, 1:29 PMlibDBClient
type is not polymorphicpakoito
02/26/2020, 1:29 PMfun <F> Observable<A>.toKind(): Kind<F, A> = effect { k().suspended() }
pakoito
02/26/2020, 1:30 PMfun <F> Mono<A>.toKind(): Kind<F, A> = effect { k().suspended() }
pakoito
02/26/2020, 1:30 PMpakoito
02/26/2020, 1:30 PMoverride fun get(): Kind<F, String> = libDBClient.get().toKind()
Gopal S Akshintala
02/26/2020, 3:55 PMinterface RepoTC<F> : Async<F> {
fun get(): Kind<F, String>
fun Mono<String>.toKind() = effect { k().suspended()!! }
fun Single<String>.toKind() = effect { k().suspended() }
}
interface NonBlockingReactorRepo<F> : RepoTC<F> {
val libDBClient: ReactorLibDBClient
override fun get(): Kind<F, String> = libDBClient.get().toKind()
}
interface NonBlockingRxRepo<F> : RepoTC<F> {
val libDBClient: RxLibDBClient
override fun get(): Kind<F, String> = libDBClient.get().toKind()
}
pakoito
02/26/2020, 3:55 PMpakoito
02/26/2020, 3:56 PMtoKind
in RepoTC
is kind of an API leak, I’d put them in a top-level object insteadGopal S Akshintala
02/26/2020, 3:56 PMGopal S Akshintala
02/26/2020, 3:58 PMeffect {}
has to be different in both functionsGopal S Akshintala
02/26/2020, 3:59 PMpakoito
02/26/2020, 6:15 PMpakoito
02/26/2020, 6:15 PMGopal S Akshintala
02/27/2020, 12:05 AMGopal S Akshintala
02/27/2020, 12:05 AM