Closed juanmrivero closed 9 months ago
@pettermahlen I updated the version to 2.0.0
and updated the baselineVersion
in binary_compatibility.gradle
to that version.
About if japicmp is enabled for mobius-coroutines, I understand by this line that it is, since the module applies the java-library plugin
This PR introduces the parameter
executionPolicy: ExecutionPolicy
too all builder functions inCoroutinesSubtypeEffectHandlerBuilder
.ExecutionPolicy
gives users simple policies to control concurrency while processing effects for each effect type in the builder. The current implemented policies are:RunSequentially
: all effects of the same type wait for the previous one to finish before executing.RunConcurrently
: all effects of the same type are executed immediately and concurrently.CancelPrevious
: a new effect of the same type start executing immediately and cancel the execution of any previously running effect.Here is an example of usage:
By default all functions use
RunSequentially
. This was selected to avoid unintended cancellations or concurrent problems while processing an effect.To support this feature the signature of the method
addEffectHandler(kClass: KClass<out F>, function: suspend (F) -> Flow<E>)
was changed toaddEffectHandler(kClass: KClass<out F>, effectHandler: EffectHandler<F, E>)
. This is non backwards compatible. I'm assuming this is ok, since the methodaddFlowProducer
, oraddFlow
(introduced in this PR) are analogous and easier to use.Additionally the function
addEffectHandler(kClass: KClass<out F>, effectHandler: EffectHandler<F, E>)
allows the user to implement its own concurrency policy by handling the effect & event channels directly in case it needs more fine grained control.This PR also introduces an utility function
MobiusCoroutines.effectHandler( coroutineContext: CoroutineContext, onEffect: suspend (effect: F, eventConsumer: Consumer<E>) -> Unit)
which creates a simple effect handler that will run all effects concurrently.Here is an example of usage: