-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shorten readme and link to project website for documentation. add gre…
…eting sample to the project website
- Loading branch information
1 parent
1cdb93b
commit 1b55fd1
Showing
5 changed files
with
78 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# InstanceKeeper | ||
|
||
## Retaining instances over configurations change | ||
|
||
Decompose provides the `InstanceKeeper` API, similar to AndroidX ViewModels: | ||
|
||
```kotlin | ||
class Child1(componentContext: ComponentContext) : ComponentContext by componentContext { | ||
private val viewModel = instanceKeeper.getOrCreate(::ViewModel) | ||
|
||
private class ViewModel : InstanceKeeper.Instance { | ||
override fun onDestroy() { | ||
// Clean-up | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# StateKeeper | ||
|
||
## Saving state over configurations change or process death | ||
|
||
Decompose provides the `StateKeeper` API for state preservation. Currently it relies on `Parcelable` interface. It can be used in multiplatform code but is only useful in Android. | ||
|
||
Here is a quick example: | ||
|
||
```kotlin | ||
class Child1(componentContext: ComponentContext) : ComponentContext by componentContext { | ||
private var state = stateKeeper.consume<State>("SAVED_STATE") ?: State() | ||
|
||
init { | ||
stateKeeper.register("SAVED_STATE") { state } | ||
} | ||
|
||
@Parcelize | ||
private class State(val someValue: Int = 0) : Parcelable | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters