Skip to content

Releases: 1gravity/Kotlin-Bloc

Synchronous reduce/dispatch

29 Jun 19:15
a911759
Compare
Choose a tag to compare
  • 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

25 Mar 03:45
Compare
Choose a tag to compare
  • migrated to a toml based version catalog
  • upgraded to Kotlin 1.8.10
  • several other dependency updates

launch returns a cancel function now

29 Oct 06:36
Compare
Choose a tag to compare

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

05 Oct 21:26
Compare
Choose a tag to compare

Migrate to Kotlin 1.7.20

initializers with reduce

04 Oct 03:57
b9e8de6
Compare
Choose a tag to compare

initializers have a reduce function now

thunk.reduce function

04 Oct 01:53
c7349e7
Compare
Choose a tag to compare
  • thunks have a reduce function
  • actions dispatched before onStart are now ignored (except when dispatched from an initializer)

v0.8.1

27 Sep 02:51
Compare
Choose a tag to compare

Fix a critical race condition in the bloc implementation

v0.8.0 improve predictability

25 Sep 02:55
8ead156
Compare
Choose a tag to compare

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

19 Sep 02:41
Compare
Choose a tag to compare

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

11 Sep 06:45
Compare
Choose a tag to compare
  • update to Kotlin 1.7.10
  • update to Compose 1.3.0
  • several other library updates