Skip to content

1.0.0-alpha01: Safe state update and new API

Pre-release
Pre-release
Compare
Choose a tag to compare
@Nek-12 Nek-12 released this 23 Nov 19:37
· 848 commits to master since this release
5565b17

What's Changed

  • 1.0.0-alpha01: Safe state update API. by @Nek-12 in #3

There are a lot of changes in this release. It's currently experimental and the API may change further.
I've decided to implement a synchronous first-in-first-serve state update api, and because of that, all the APIs that exposed current state without properly handling the parallelism of updates were removed.

Breaking changes:

  • Removed currentState. Use withState() instead.
  • Added withState() function that obtains a current state, then runs the given block while suspending every other client from accessing the state until that block is finished. This is done because by obtaining state and then mutating it, you inherently introduce race conditions to your code, and now the management of that is being done out of the box by the library. Previously, you had to keep track of those yourself
  • State can now still be obtained and assigned as the state property, but these APIs are considered delicate and may be removed in the future if no use cases for them are found.
  • added new inline functions updateState and withState that work differently from the withState we were used to use. withState now operates on a state, but does not change it, and updateState updates the state with the return value of its block. Proper contracts were implemented for them.
  • There are now new inline functions for updateState and withState that work the same as the previous withState function - if state does not match given type, the block isn't executed and state is not updated.
  • reduce() now has no return value. This is because users of the library don't always need to update the state. Often an intent reduction results just in an action or other processing being done.
  • removed set(state) from the api
  • launchForState is now called launchRecovering and does not require a state return value. It's now exposed via store and it's reducer scope
  • Introduced new typealiases for lambdas of recover and reduce
  • The preferred way of creating and launching the store is lazyStore() (not launched) and launchedStore() (created and launched on first access)
  • MVIIntentScope no longer implements CoroutineScope but rather has a scope property
  • KMM migration plans are set in place. The library will get to the beta when the KMM migration is done for the core module.
  • Tests are now fully passing. Code coverage is on its way.
  • Store.launch() is now Store.start()
  • MVIIntentScope no longer implements MVIProvider to not let users abuse some functions like sending intents out of the reduce block anymore.
  • All deps were updated to latest stable versions, namely kotlin (1.7.21) and compose (1.3.1 with compiler 1.4.0-alpha02)

Full Changelog: 0.2.6...1.0.0-alpha01