Releases: FunnySaltyFish/ComposeDataSaver
v1.2.3 released! iOS & WASM are supported now!
ComposeDataSaver v1.2.3
🚀 What's New
- Bump Kotlin to 2.2.0 & Compose to 1.8.2
- Fix errors due to re-usage of cipher in DataSaverEncryptedProperties, support
enableFileMonitoringandenableDataIntegrityCheckfor it - New Platform Support
- iOS: Native NSUserDefaults integration with KVO monitoring with rich data types (ByteArray, List, Map, NSDate, URL)
- WASM: Browser localStorage support for web applications
新特性
- 升级 Kotlin 至 2.2.0 & Compose 至 1.8.2
- 修复 DataSaverEncryptedProperties 中因 cipher 复用导致的数据读取问题,并提供了数据完整性校验以及文件外部修改检测的功能
- 新平台支持
- iOS: 原生 NSUserDefaults 集成,支持 KVO 监听,支持多种数据类型(ByteArray、List、Map、NSDate、URL)
- WASM: 浏览器 localStorage 支持,适用于 Web 应用
Full Changelog: v1.2.2...v.1.2.3
v1.2.2
v1.2.2
- 升级 Compose 至 1.7.0、Kotlin 至 2.0.0
LocalDataSaver改为val#9DataSaverProperties系列支持传入编码 #8- 重要:为了编码的通用性,新的编码默认指定为 UTF-8,这与 Properties 的默认编码并不一致。如果您之前使用过此类存储数据,请注意手动指定编码为原先文件的编码,否则可能导致数据丢失!!!
rememberDataSaverState支持直接传入typeConverter,此优先级高于全局注册,有助于解决多个Converter都满足条件时导致的选择错误问题DataSaverConfig现在可以指定logger,以接入你自己的 logger。默认的桌面端输出有颜色了
感谢 GitHub 用户 @XingMingYue @Nyayurin @Kyant0,感谢热心的邮箱用户 graveyard233 提的建议。感谢所有愿意尝试此库的小伙伴们
Full Changelog: v1.2.1...v1.2.2
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
SnapShotStateListto implementDataSaverListStateto improve performance, you should use its method likeadd/remoeveto 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.5and so on
Full Changelog: v1.1.7...v1.1.8
v1.1.7 released
About the lib
- add
coroutineScopeparameter, so you can pass your custom coroutineScope toDataSaverState - make
mutableDataSaverStateOfwith paramterautoSavedeprecated, you can use AS to replace automatically - make DataSaverXXX classes open & job public and observable
About the sample
- refactor the code, add
AppConfigto 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
DataSaverInterfacefrominterfacetoabstract 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
implementationtocompileOnly - 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
nullvalue forregisterTypeConverter - place method
registerTypeConverterintoobject DataSaverConverter - change the initialization way of
DataSaverPerference,DataSaverMMKVandDataSaverDataStorePreference - add function
remove(key: String)inDataSaverInterfaceand corresponding methodremove(replacement)inDataSaver[List]State