Skip to content

Commit

Permalink
readme upd
Browse files Browse the repository at this point in the history
  • Loading branch information
y9san9 committed Jun 12, 2021
1 parent b394ca9 commit 280ca91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ You can also store android app state with the library
```kotlin
class MainActivity : Activity() {
private val state = object : KBundleDataStorage() {
val buttonClicked by int { 0 }
var score by int { 0 } // This will be automatically saved and restored
}

override fun onCreate(bundle: Bundle?) = state.fillState(bundle) {
super.onCreate(bundle)
...
}
// OR
override fun onCreate(bundle: Bundle?) {
Expand All @@ -72,6 +71,7 @@ class MainActivity : Activity() {
}
}
```
`property` are also allowed there with serialization to string followed by `bundle.putString`


### Mutate Example
Expand All @@ -86,15 +86,15 @@ object MainStorage : ... {
}

// Launches an asynchronous commit after block()
fun addItem() = MainStorage.mutate {
fun editItem() = MainStorage.mutate {
item.foo = ...
}
// Suspends until commit
suspend fun addItem() = MainStorage.mutateCommit {
suspend fun editItem() = MainStorage.mutateCommit {
item.foo = ...
}
// Blocking mutation
fun addItem() = MainStorage.mutateBlocking {
fun editItem() = MainStorage.mutateBlocking {
item.foo = ...
}

Expand Down

0 comments on commit 280ca91

Please sign in to comment.