Skip to content

Commit

Permalink
migration to coroutines 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondeye authored and daely committed Nov 7, 2018
1 parent 106a334 commit 9bfa2b7
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import com.beyondeye.reduks.middlewares.applyMiddleware
import com.beyondeye.reduksAndroid.activity.ActionRestoreState
import com.beyondeye.reduksAndroid.activity.ReduksActivity
import com.beyondeye.reduksAndroid.activity.ReduksActivity.Companion.defaultReduksInternalLogger
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.android.UI
import kotlinx.coroutines.*

/**
* An activity base class for avoiding writing boilerplate code for initializing reduks and handling save and restoring reduks state
Expand All @@ -20,6 +19,7 @@ import kotlinx.coroutines.experimental.android.UI
* Created by daely on 6/13/2016.
*/
abstract class AsyncReduksActivity<S:Any>(
val activity_cscope: CoroutineScope=GlobalScope,
/**
* if true, then create activate sagaMiddleware, and automatically stop it on activity destroy
*/
Expand All @@ -36,13 +36,13 @@ abstract class AsyncReduksActivity<S:Any>(
super.onCreate(savedInstanceState)
reduks=initReduks()
if(withSagaMiddleWare) {
sagaMiddleware = SagaMiddleWare(reduks.store)
sagaMiddleware = SagaMiddleWare(reduks.store,activity_cscope)
reduks.store.applyMiddleware(sagaMiddleware!!)
}
reduks.store.errorLogFn=defaultReduksInternalLogger
}

override fun <T> storeCreator(): StoreCreator<T> = AsyncStore.Creator<T>(reduceContext = CommonPool,subscribeContext = UI)
override fun <T> storeCreator(): StoreCreator<T> = AsyncStore.Creator<T>(cscope=activity_cscope,reduceContext = Dispatchers.Default,subscribeContext = Dispatchers.Main)

//override for making this function visible to inheritors
override fun onStop() {
Expand Down

0 comments on commit 9bfa2b7

Please sign in to comment.