Skip to content

Commit

Permalink
fix: reintroduce workaround for https://youtrack.jetbrains.com/issue/…
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Sep 11, 2024
1 parent 24d782c commit 53f9fb7
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public fun <S : MVIState, I : MVIIntent, A : MVIAction> compositePlugin(
onState = { old: S, new: S -> plugins.chain(new) { next -> onState(old, next) } },
onIntent = { intent: I -> plugins.chain(intent) { onIntent(it) } },
onAction = { action: A -> plugins.chain(action) { onAction(it) } },
onException = { e: Exception -> plugins.chain(e) { onException(it) } },
onException = { e: Exception -> plugins.chainException(e) { onException(it) } },
onSubscribe = { subs: Int -> plugins.chain { onSubscribe(subs) } },
onUnsubscribe = { subs: Int -> plugins.chain { onUnsubscribe(subs) } },
onStart = { plugins.chain { onStart() } },
Expand All @@ -42,3 +42,9 @@ private inline fun <R, S : MVIState, I : MVIIntent, A : MVIAction> List<StorePlu
initial: R,
block: StorePlugin<S, I, A>.(R) -> R?
) = fastFold<_, R?>(initial) inner@{ acc, it -> block(it, acc ?: return@chain acc) }

// TODO: https://youtrack.jetbrains.com/issue/KT-68509
private inline fun <S : MVIState, I : MVIIntent, A : MVIAction> List<StorePlugin<S, I, A>>.chainException(
initial: Exception,
block: StorePlugin<S, I, A>.(Exception) -> Exception?
) = fastFold<_, Exception?>(initial) inner@{ acc, it -> block(it, acc ?: return@chainException acc) }

0 comments on commit 53f9fb7

Please sign in to comment.