Releases: FunnySaltyFish/ComposeDataSaver
Releases · FunnySaltyFish/ComposeDataSaver
v1.2.1 released
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 !
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!
Note:
- revert the changes in v1.1.8 of
DataSaverListState
. When usingStateList
, it is impossible to save data when the list has been changed, sorry for the incorrectness.
v1.1.8 released!
Breaking changes
- use
SnapShotStateList
to implementDataSaverListState
to improve performance, you should use its method likeadd
/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 to1.9.20
, compose complier to1.5.5
and so on
Full Changelog: v1.1.7...v1.1.8
v1.1.7 released
About the lib
- add
coroutineScope
parameter, so you can pass your custom coroutineScope toDataSaverState
- make
mutableDataSaverStateOf
with paramterautoSave
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!
v1.1.6
Breaking Changes
- change
DataSaverInterface
frominterface
toabstract 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
tocompileOnly
- clean logger's code
v1.1.5 released !
- add support for sealed class
- actually, this means that if you call
registerTypeConverters<A>
, then classes that extends from A will be supported automatically
- actually, this means that if you call
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
- support
null
value forregisterTypeConverter
- place method
registerTypeConverter
intoobject DataSaverConverter
- change the initialization way of
DataSaverPerference
,DataSaverMMKV
andDataSaverDataStorePreference
- add function
remove(key: String)
inDataSaverInterface
and corresponding methodremove(replacement)
inDataSaver[List]State
1.1.3 released!
- add source code to jitpack.io (I hope it works, finally)
1.1.2 released!
- Add
Parcelable
andByteArray
support tosaveData
method ofMMKV
implementation - Try to add source code when uploading to
jitpack.io