You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README_en.md
+35-14Lines changed: 35 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,13 @@ class MyViewModel: ViewModel() {
37
37
38
38
**Note: This library is a wrapper for using other frameworks (such as Preference, MMKV, DataStore, etc.) in Compose, not a standalone data storage framework**. You can refer to [this link](https://juejin.cn/post/7144750071156834312) to understand its design concepts.
> Note: Starting from v1.2.0, the repository has been migrated to Compose Multiplatform and released to Maven Central. The Group Id has also been changed. When upgrading from versions before v1.2.0, please remember to make the necessary changes.
66
72
67
73
## Sample Code
68
74
The sample codes described below can be viewed in detail [here](composeApp/src/commonMain/kotlin/com/funny/data_saver/ui/ExampleComposables.kt).
69
75
76
+
The demo app uses a grouped layout and includes a log sidebar, so you can inspect read/write logs and state changes more easily.
77
+
70
78
## Configuration
71
79
72
80
The project uses an implementation class of `DataSaverInterface` to save data, so **you need to provide an object of this class first.**
@@ -91,11 +99,7 @@ Additionally, we also provide simple implementations based on [MMKV](https://git
Currently, the library provides some parameters that can be set under `DataSaverConfig`.
398
+
The library now provides leveled logging configuration under `DataSaverConfig`:
395
399
396
400
```kotlin
397
-
/**
398
-
* 1. DEBUG: Whether to output debug information of the library
399
-
*/
400
401
object DataSaverConfig {
401
-
var DEBUG = true
402
+
var logLevel: DataSaverLogLevel = DataSaverLogLevel.INFO
402
403
}
403
404
```
404
405
406
+
Available levels:
407
+
408
+
```kotlin
409
+
enum class DataSaverLogLevel {
410
+
NONE,
411
+
ERROR,
412
+
WARNING,
413
+
INFO,
414
+
DEBUG,
415
+
VERBOSE
416
+
}
417
+
```
418
+
419
+
The default level is `INFO`. With the default configuration, important logs such as read, restore, write, remove, and external data change events are visible out of the box.
420
+
421
+
> Note:
422
+
>
423
+
> 1. `DataSaverLogger` has been removed. If you referenced it directly before, migrate to `Log`
424
+
> 2. `DataSaverConfig.DEBUG` is still kept as a compatibility entry point, but `DataSaverConfig.logLevel` is now the recommended API
425
+
405
426
### Asynchronous Saving
406
427
407
428
In version 1.1.0, `suspend fun saveDataAsync` was added to `DataSaverInterface` for asynchronous saving. By default, it is equivalent to `saveData`. For frameworks that support coroutines (such as `DataStore`), using this implementation helps to fully leverage the advantages of coroutines (the default `DataStorePreference` does this).
0 commit comments