we are planning to do a different
bind
solution on extra requirements in our android state management. We wanted to bring in
Async
work into our scope and also provide an environment for the binding.
something similar:
public suspend fun <E : Environment, ER, R> EitherScope<E, ER>.bind(
f: suspend E.() -> Either<R, ER>,
) : R
public suspend fun <E : Environment, ER, R> EitherScope<E, ER>.bindAsync(
f: suspend E.() -> Either<R, ER>,
) : Deferred<R>
instead of binding on the
Either
type we bind on the scope and the bind argument return value will be evaluated.
usage:
either {
val a = bind { this.myNetworkCall() }
val b = bindAsync { this.myNetworkCall2() }
b.await()
}