Skip to content

Commit

Permalink
we need to create a new CoroutineScope if the old one was cancelled
Browse files Browse the repository at this point in the history
  • Loading branch information
1gravity committed Sep 11, 2022
1 parent 2cac924 commit 2c48b24
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ Note, this readme offers a quick overview of the framework. For more in-depth in
```kotlin
dependencies {
// the core library
implementation("com.1gravity:bloc-core:0.6.1")
implementation("com.1gravity:bloc-core:0.6.2")

// add to use the framework together with Redux
implementation("com.1gravity:bloc-redux:0.6.1")
implementation("com.1gravity:bloc-redux:0.6.2")

// useful extensions for Android and Jetpack/JetBrains Compose
implementation("com.1gravity:bloc-compose:0.6.1")
implementation("com.1gravity:bloc-compose:0.6.2")
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ internal class BlocImpl<State : Any, Action : Any, SideEffect : Any, Proposal :
BlocObserver<State>?, sideEffect:
BlocObserver<SideEffect>?
) {
val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

observerLifecycle.doOnStart {
val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

logger.d("start Bloc subscription")
state?.let {
coroutineScope.launch {
Expand All @@ -107,11 +107,11 @@ internal class BlocImpl<State : Any, Action : Any, SideEffect : Any, Proposal :
sideEffects.collect { sideEffect(it) }
}
}
}

observerLifecycle.doOnStop {
logger.d("stop Bloc subscription")
coroutineScope.cancel("stop Bloc subscription")
observerLifecycle.doOnStop {
logger.d("stop Bloc subscription")
coroutineScope.cancel("stop Bloc subscription")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public fun <State : Any, Action : Any, SideEffect : Any> Bloc<State, Action, Sid
state: (suspend (state: State) -> Unit)? = null,
sideEffect: (suspend (sideEffect: SideEffect) -> Unit)? = null
) {
val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

lifecycle.doOnStart {
logger.d("start Bloc subscription")

val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)

state?.let {
coroutineScope.launch {
collect { state(it) }
Expand All @@ -39,11 +39,11 @@ public fun <State : Any, Action : Any, SideEffect : Any> Bloc<State, Action, Sid
sideEffects.collect { sideEffect(it) }
}
}
}

lifecycle.doOnStop {
logger.d("stop Bloc subscription")
coroutineScope.cancel("stop Bloc subscription")
lifecycle.doOnStop {
logger.d("stop Bloc subscription")
coroutineScope.cancel("stop Bloc subscription")
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ kotlin.internal.mpp.hierarchicalStructureByDefault=true

# Maven
POM_GROUP=com.1gravity
POM_VERSION_NAME=0.6.1
POM_VERSION_NAME=0.6.2
# set PUBLISH_AS_SNAPSHOT to false to publish a release version
PUBLISH_AS_SNAPSHOT=true

Expand Down
6 changes: 3 additions & 3 deletions versions.properties
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ version.androidx.recyclerview=1.2.1
## # available=1.3.0-beta02

## unused
version.com.1gravity..bloc-compose=0.6.1
version.com.1gravity..bloc-compose=0.6.2

## unused
version.com.1gravity..bloc-redux=0.6.1
version.com.1gravity..bloc-redux=0.6.2

## unused
version.com.1gravity..bloc-core=0.6.1
version.com.1gravity..bloc-core=0.6.2

version.com.1gravity..redux-kotlin-threadsafe=0.5.10

Expand Down
6 changes: 3 additions & 3 deletions website/docs/getting_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ hide_title: true
```kotlin
dependencies {
// the core library
implementation("com.1gravity:bloc-core:0.6.1")
implementation("com.1gravity:bloc-core:0.6.2")

// add to use the framework together with Redux
implementation("com.1gravity:bloc-redux:0.6.1")
implementation("com.1gravity:bloc-redux:0.6.2")

// useful extensions for Android and Jetpack/JetBrains Compose
implementation("com.1gravity:bloc-compose:0.6.1")
implementation("com.1gravity:bloc-compose:0.6.2")
}
```

0 comments on commit 2c48b24

Please sign in to comment.