Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arkivanov committed Oct 23, 2024
1 parent f301498 commit 8af551e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion docs/component/instance-retaining.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ class SomeComponent(
}
```

## Usage example (experimental since version 3.2.0-alpha02)
## Simplified usage example

!!!warning

The `retainedInstance` API is experimental since version `3.2.0-alpha02`, stable since `3.2.0`.

```kotlin
import com.arkivanov.decompose.ComponentContext
Expand Down
18 changes: 14 additions & 4 deletions docs/component/state-preservation.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ class SomeStatefulEntity(savedState: State?) : InstanceKeeper.Instance {
}
```

## Usage examples (experimental since version 3.2.0-alpha02)
## Simplified state preservation

```kotlin title="Saving state in a component"
!!!warning

The `saveable` API is experimental since version `3.2.0-alpha02`.

```kotlin
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.essenty.statekeeper.saveable
import kotlinx.serialization.Serializable
Expand All @@ -66,11 +70,17 @@ class SomeComponent(componentContext: ComponentContext) : ComponentContext by co
private var state: State by saveable(serializer = State.serializer(), init = ::State)

@Serializable // Comes from kotlinx-serialization
private class State(val someValue: Int = 0)
private data class State(val someValue: Int = 0)
}
```

```kotlin title="Saving state of a retained instance"
## Simplified state preservation of a retained instance

!!!warning

The `retainedInstance` API is experimental since version `3.2.0-alpha02`, stable since `3.2.0`.

```kotlin
import com.arkivanov.decompose.ComponentContext
import com.arkivanov.essenty.instancekeeper.InstanceKeeper
import com.arkivanov.essenty.instancekeeper.retainedInstance
Expand Down

0 comments on commit 8af551e

Please sign in to comment.