Skip to content

Commit

Permalink
chore: fix code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Nov 5, 2024
1 parent a61c124 commit 5a84103
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal class StoreImpl<S : MVIState, I : MVIIntent, A : MVIAction>(

override fun start(scope: CoroutineScope) = launchPipeline(
parent = scope,
config = config,
storeConfig = config,
onAction = { action -> onAction(action)?.let { this@StoreImpl.action(it) } },
onTransformState = { transform ->
this@StoreImpl.updateState { onState(this, transform()) ?: this }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import pro.respawn.flowmvi.api.lifecycle.StoreLifecycle
@OptIn(DelicateStoreApi::class)
internal inline fun <S : MVIState, I : MVIIntent, A : MVIAction, T> T.launchPipeline(
parent: CoroutineScope,
config: StoreConfiguration<S>,
storeConfig: StoreConfiguration<S>,
crossinline onStop: (e: Exception?) -> Unit,
crossinline onAction: suspend PipelineContext<S, I, A>.(action: A) -> Unit,
crossinline onTransformState: suspend PipelineContext<S, I, A>.(transform: suspend S.() -> S) -> Unit,
Expand All @@ -54,19 +54,19 @@ internal inline fun <S : MVIState, I : MVIIntent, A : MVIAction, T> T.launchPipe
StoreLifecycleModule by storeLifecycle(job),
ActionReceiver<A> {

override val config get() = config
override val config = storeConfig
override val key = PipelineContext // recoverable should be separate from this key
private val handler = PipelineExceptionHandler()
private val pipelineName = CoroutineName(toString())

override val coroutineContext = parent.coroutineContext +
config.coroutineContext +
storeConfig.coroutineContext +
pipelineName +
job +
handler +
this

override fun toString(): String = "${config.name.orEmpty()}PipelineContext"
override fun toString(): String = "${storeConfig.name.orEmpty()}PipelineContext"

override suspend fun updateState(transform: suspend S.() -> S) = catch { onTransformState(transform) }
override suspend fun action(action: A) = catch { onAction(action) }
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ kotlin-io = "0.5.4"
kotlinx-atomicfu = "0.26.0"
ktor = "3.0.1"
lifecycle = "2.8.3"
androidx-lifecycle = "2.8.7"
# @pin
#noinspection GradleDependency - must match jb-lifecycle
androidx-lifecycle = "2.8.3"
maven-publish-plugin = "0.30.0"
serialization = "1.7.3"
turbine = "1.2.0"
Expand Down

0 comments on commit 5a84103

Please sign in to comment.