Releases: 1gravity/Kotlin-Bloc
Releases · 1gravity/Kotlin-Bloc
Synchronous reduce/dispatch
- When triggered from initializers and thunks, reducers run "synchronously" now. This solves the problem in thunks/reducers if they dispatch actions or reduce state directly and expect getState() to return the reduced value which isn't always the case if reducers run asynchronously. With "synchronous" we mean that the execution of the thunk/initializer is suspended till the reducer has actually run (it's still queued and executed asynchronously)
- Fix a race condition when using a viewModelScope to control the Bloc's lifecycle
- Several library updates
Version Catalog + Kotlin 1.8.10
- migrated to a toml based version catalog
- upgraded to Kotlin 1.8.10
- several other dependency updates
launch returns a cancel function now
Launch returns a Cancel function that can be used to cancel the coroutine "manually:
private var cancel: Cancel? = null
fun onSelected(post: Post) = thunk {
// only load if not already being loaded and if a different post was selected
if (loadingJob != null && state.id != post.id) {
cancel = launch {
load(post)
}
}
}
fun onDestroy() {
cancel?.invoke()
// more cleanup
}
Migrate to Kotlin 1.7.20
Migrate to Kotlin 1.7.20
initializers with reduce
initializers have a reduce function now
thunk.reduce function
- thunks have a reduce function
- actions dispatched before onStart are now ignored (except when dispatched from an initializer)
v0.8.1
v0.8.0 improve predictability
To make the library more predictable (one of the three architectural goals) the following changes were made:
- the Essenty lifecycle is translated to a Bloc lifecycle using a state machine
- initializers are now executed completely before thunks or reducers are
- MVVM+ style initializers were removed because they could be submitted at any time and thus the state machine could never progress to Started state
- if a bloc is stopped, actions, thunks, reducers etc. submitted to the bloc will be ignored
- if a bloc is running the initializer actions, thunks, reducers etc. submitted to the bloc will be queued for later execution
- reducers need to run synchronously -> they are no longer suspend but just regular functions
launch coroutines from initializers, thunks & reducers
coroutines can now be launched from initializers, thunks and reducers like this:
thunk {
launch(JobConfig(true)) {
load(post)
}
}
With JobConfig(true)) previously launched coroutines would be cancelled before the new one is started.
Update to Kotlin 1.7.0
- update to Kotlin 1.7.10
- update to Compose 1.3.0
- several other library updates