If I have a coroutine suspend function that return...
# arrow
r
If I have a coroutine suspend function that returns an Either<Error, Foo>, is there a way to combine the scopes?
scope.launch { either { val x = x().bind
shouldn’t compile, because
x()
needs to be called from a coroutine scope.
either { scope.launch { val x = x().bind
should fail at runtime, since the bind exception can’t be caught by the
either
, right? So, what can I do?
s
If the function is supsending already, can you not skip the scope.launch in the first place?
r
The outer function isn’t suspending, so I need a scope if I want to call x.
y
That first option should just work!
either
is
inline
, so it's transparent to
suspend
☝️ 1
mind blown 1
r
Great, thanks!