Skip to content

Commit

Permalink
fix issues with parent store job handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Dec 1, 2023
1 parent 2fd1b67 commit 9a334bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public fun <K : Any, S : MVIState, I : MVIIntent, A : MVIAction> jobManagerPlugi
* @return the [JobManager] instance that was created for this plugin.
*/
@FlowMVIDSL
public fun <A : MVIAction, I : MVIIntent, S : MVIState> StoreBuilder<S, I, A>.manageJobs(
public fun <A : MVIAction, I : MVIIntent, S : MVIState, T : Any> StoreBuilder<S, I, A>.manageJobs(
name: String = JobManager.Name
): JobManager<String> = JobManager<String>().also {
): JobManager<T> = JobManager<T>().also {
install(jobManagerPlugin(it, name))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.respawn.flowmvi.plugins

import kotlinx.coroutines.coroutineScope
import pro.respawn.flowmvi.api.FlowMVIDSL
import pro.respawn.flowmvi.api.MVIAction
import pro.respawn.flowmvi.api.MVIIntent
Expand Down Expand Up @@ -35,7 +36,10 @@ public inline fun <
@BuilderInference crossinline consume: suspend PipelineContext<S, I, A>.(action: A2) -> Unit,
@BuilderInference crossinline render: suspend PipelineContext<S, I, A>.(state: S2) -> Unit,
): StorePlugin<S, I, A> = whileSubscribedPlugin(name = name, minSubscriptions = minExternalSubscriptions) {
subscribe(parent, { consume(it) }, { render(it) }).join()
// do not use pipeline context to cancel subscription properly, suspend instead
coroutineScope {
subscribe(parent, { consume(it) }, { render(it) }).join()
}
}

/**
Expand Down Expand Up @@ -65,7 +69,9 @@ public inline fun <S : MVIState, I : MVIIntent, A : MVIAction, S2 : MVIState, I2
minExternalSubscriptions: Int = 1,
@BuilderInference crossinline render: suspend PipelineContext<S, I, A>.(state: S2) -> Unit,
): StorePlugin<S, I, A> = whileSubscribedPlugin(name = name, minSubscriptions = minExternalSubscriptions) {
subscribe(parent) { render(it) }.join()
coroutineScope {
subscribe(parent) { render(it) }.join()
}
}

/**
Expand Down

0 comments on commit 9a334bd

Please sign in to comment.