-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
arrow-fx-coroutines/src/main/kotlin/arrow/fx/coroutines/Enviroment.kt
Outdated
Show resolved
Hide resolved
* | ||
* This contract could be elaborated on Android to provide automatic cancellation on Android LifecycleOwner. | ||
*/ | ||
interface Environment { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the implementation. Can't wait to use it! 😃
arrow-fx-coroutines/src/main/kotlin/arrow/fx/coroutines/Enviroment.kt
Outdated
Show resolved
Hide resolved
Thanks @joramnv for the code review! 🙌 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nits but looks good!
Co-authored-by: Jorge Castillo <jorge.castillo.prz@gmail.com>
|
||
/** | ||
* Execution strategies that will immediately return and perform the program's work without blocking the current thread. | ||
* This operation runs uncancellable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth adding a note about how exceptions are handled in this particular case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to see this idea evolve :D
This PR proposes an [Enviroment] interface, that can be used instead of the bare bones runners which don't provide elegant syntax.
The Enviroment type offers the same runners as
UnsafeRun
currently offers forF
.It however also incorporates
CoroutineContext
andasyncErrorHandler
.asyncErrorHandler
would currently be called only forcancellableF
when it's returnedCancelToken
throws an exception. ref.CoroutineContext
defines an initial ctx forunsafeRunSync
so we don't need anEventLoop
. This however means that by defaultunsafeRunSync
called frommain
runs onForkJoinPool
.Alternative would be to start on
EmptyCoroutineContext
but then we'd return the user toForkJoinPool
after the firstsleep
or other parallel op.