Skip to content

Releases: FunnySaltyFish/ComposeDataSaver

v1.2.1 released

24 Jul 14:45
Compare
Choose a tag to compare

v1.2.1

破坏性变更:移除 DataSaverListState 及相关类

不再支持 rememberDataSaverListState 以及相关内容。创建此类的初衷是希望能够对 List 的操作做一些优化,但实际上,由于 mutableStateListOf 返回的 SnapshotStateList 也无法被继承,因此在旧版实现中,其相对于 DataSaverState<List<T>> 并无任何性能优势,有些冗余。且新版实现在 findRestorer 上无法传入某一个值,代码不太好写,故最终去除

迁移指南

  • 如果之前没有用到过此类:那么新的直接用 mutableDataSaverState<List<ExampleBean>("key", emptyList()) 这种即可,且需要注册转换器,但务必注明具体泛型。否则此变量将被推断为 List<Any>,转换器无法正常工作
  • 如果之前有用到,且希望保留数据,在迁移到 mutableDataSaverState 的同时,您还需要注册新的转换器以支持 List<Bean>同时,由于之前默认的分隔符是 #@#,与大多数框架的 , 不同,您需要在 restore 时转换一下
registerTypeConverters<ExampleBean>(
	save = { bean -> Json.encodeToString(bean) },
	restore = { str -> Json.decodeFromString(str.replace("#@#", ",")) }
)

其他更改

  • 支持 emptyList/emptyMap 作为默认值(#7
  • 增强 registerTypeConverters,现在除了通过类判断,也可以自行传入判断条件
  • 在 JVM Desktop 端新增 DataSaverEncryptedProperties,用于保存加密的键值对数据
  • 引入了 kotlin-reflect 的依赖库,这是为了多平台做准备。之前的 ::class.java 在 JVM 以外平台无法使用。将在下一版新增其他平台

Full Changelog: v1.2.0...v1.2.1

v1.2.0 release! Now for Compose Multiplatform !

08 Feb 03:28
Compare
Choose a tag to compare

The library has been migrated to Compose Multiplatform (Android / JVM Desktop) since v1.2.0, and the publish repository has been changed from jitpack to Maven Central. Check README to see the new group id.

v1.1.9 released!

08 Dec 06:37
Compare
Choose a tag to compare

Note:

  • revert the changes in v1.1.8 of DataSaverListState. When using StateList, it is impossible to save data when the list has been changed, sorry for the incorrectness.

v1.1.8 released!

04 Dec 16:21
Compare
Choose a tag to compare

Breaking changes

  • use SnapShotStateList to implement DataSaverListState to improve performance, you should use its method like add/remoeve to modify the data

Updates

  • add error handler when restoring, when error occurs, the data will be reset to initialValue
  • bump Compose bom to 2023.10.01, kotlin to 1.9.20, compose complier to 1.5.5 and so on

Full Changelog: v1.1.7...v1.1.8

v1.1.7 released

06 Sep 09:42
Compare
Choose a tag to compare

About the lib

  • add coroutineScope parameter, so you can pass your custom coroutineScope to DataSaverState
  • make mutableDataSaverStateOf with paramter autoSave deprecated, you can use AS to replace automatically
  • make DataSaverXXX classes open & job public and observable

About the sample

  • refactor the code, add AppConfig to manage the dataSaver
  • add samples of using the state in ViewModel and doing time-consuming jobs

Special thanks to one staff who works in BiliBili, he gave me these advice.

v1.1.6 released!

09 Jul 11:53
Compare
Choose a tag to compare

v1.1.6

Breaking Changes

  • change DataSaverInterface from interface to abstract class

Other Changes

  • support @Preview, including normally preview and simple interactive mode
  • support simple senseExternalDataChange (see readme and ExampleComposables.kt)
  • update compose version to BOM 2023.06.01
  • replace some implementation to compileOnly
  • clean logger's code

v1.1.5 released !

12 Mar 10:29
Compare
Choose a tag to compare
  • add support for sealed class
    • actually, this means that if you call registerTypeConverters<A>, then classes that extends from A will be supported automatically
sealed class ThemeType(val id: Int) {
    object StaticDefault: ThemeType(-1)
    object DynamicNative : ThemeType(0)
    class DynamicFromImage(val color: Color) : ThemeType(1)
    class StaticFromColor(val color: Color): ThemeType(2)
}

you can call

registerTypeConverters<ThemeType>(save = ThemeType.Saver, restore = ThemeType.Restorer)

to support converting it.

  • add a function getGenericType() to obtain the actual type of an Object

v1.1.4 released

20 Nov 03:04
Compare
Choose a tag to compare
  • support null value for registerTypeConverter
  • place methodregisterTypeConverter into object DataSaverConverter
  • change the initialization way of DataSaverPerference, DataSaverMMKV and DataSaverDataStorePreference
  • add function remove(key: String) in DataSaverInterface and corresponding method remove(replacement) in DataSaver[List]State

1.1.3 released!

06 Nov 14:16
Compare
Choose a tag to compare
  • add source code to jitpack.io (I hope it works, finally)

1.1.2 released!

06 Nov 13:06
Compare
Choose a tag to compare
  • Add Parcelable and ByteArray support to saveData method of MMKV implementation
  • Try to add source code when uploading to jitpack.io