-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
497 additions
and
1 deletion.
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,7 @@ | ||
/ | ||
|
||
## All modules: | ||
|
||
| Name | | ||
|---| | ||
| [statex-core](statex-core/index.md) | | |
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,25 @@ | ||
$dokka.format:gfm-v1 | ||
$dokka.linkExtension:md | ||
$dokka.location:com.mooncloak.kodetools.statex////PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex//change/com.mooncloak.kodetools.statex.MutableStateContainer[TypeParam(bounds=[kotlin.Any?])]#TypeParam(bounds=[kotlin.Any?])/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/change.md | ||
$dokka.location:com.mooncloak.kodetools.statex//mutableStateContainerOf/#TypeParam(bounds=[kotlin.Any?])/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/mutable-state-container-of.md | ||
$dokka.location:com.mooncloak.kodetools.statex/MutableStateContainer.Companion///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/-companion/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/MutableStateContainer///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/MutableStateContainer/change/#kotlin.coroutines.SuspendFunction1[TypeParam(bounds=[kotlin.Any?]),TypeParam(bounds=[kotlin.Any?])]/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/change.md | ||
$dokka.location:com.mooncloak.kodetools.statex/MutableStateContainer/reset/#TypeParam(bounds=[kotlin.Any?])/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/reset.md | ||
$dokka.location:com.mooncloak.kodetools.statex/PlatformViewModel///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-platform-view-model/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer.Companion///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/-companion/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer/changed/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/changed.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer/current/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/current.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer/initial/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/initial.md | ||
$dokka.location:com.mooncloak.kodetools.statex/StateContainer/stream/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/stream.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel.Companion///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/-companion/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel///PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/index.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel/ViewModel/#TypeParam(bounds=[kotlin.Any?])/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/-view-model.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel/bind/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/bind.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel/isBound/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/is-bound.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel/state/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/state.md | ||
$dokka.location:com.mooncloak.kodetools.statex/ViewModel/unbind/#/PointingToDeclaration/statex-core/statex-core/com.mooncloak.kodetools.statex/-view-model/unbind.md | ||
module:statex-core | ||
com.mooncloak.kodetools.statex |
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,9 @@ | ||
//[statex-core](index.md) | ||
|
||
# statex-core | ||
|
||
## Packages | ||
|
||
| Name | | ||
|---| | ||
| [com.mooncloak.kodetools.statex](statex-core/com.mooncloak.kodetools.statex/index.md) | |
6 changes: 6 additions & 0 deletions
6
...ore/com.mooncloak.kodetools.statex/-mutable-state-container/-companion/index.md
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,6 @@ | ||
//[statex-core](../../../../index.md)/[com.mooncloak.kodetools.statex](../../index.md)/[MutableStateContainer](../index.md)/[Companion](index.md) | ||
|
||
# Companion | ||
|
||
[common]\ | ||
object [Companion](index.md) |
31 changes: 31 additions & 0 deletions
31
...e/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/change.md
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,31 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[MutableStateContainer](index.md)/[change](change.md) | ||
|
||
# change | ||
|
||
[common]\ | ||
abstract suspend fun [change](change.md)(block: suspend (current: [T](index.md)) -> [T](index.md)) | ||
|
||
Updates the [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md) value to be the value obtained by invoking the provided [block](change.md) function. The [block](change.md) function is invoked within a lock, so subsequent calls to read the contained state values, such as [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md), are guaranteed to return the same value, as no other mutations can occur until after the function returns and its result is emitted. | ||
|
||
The provided [block](change.md) function is provided the [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md) value for convenience. Though, explicitly accessing the [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md) value will return the same value. | ||
|
||
!Note All write operations for a [MutableStateContainer](index.md) are safe to access concurrently. This means that if another mutation is currently running while this function is invoked, then this function will suspend until that function has finished. | ||
|
||
## Example Usage | ||
|
||
```kotlin | ||
stateContainer.change { current -> | ||
// Perform some logic | ||
|
||
// Return an updated value from this function | ||
current.copy(...) | ||
} | ||
``` | ||
|
||
#### Parameters | ||
|
||
common | ||
|
||
| | | | ||
|---|---| | ||
| block | The function that will be invoked to obtain the new [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md) value. | |
38 changes: 38 additions & 0 deletions
38
...re/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/index.md
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,38 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[MutableStateContainer](index.md) | ||
|
||
# MutableStateContainer | ||
|
||
@[Stable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Stable.html) | ||
|
||
interface [MutableStateContainer](index.md)<[T](index.md)> : [StateContainer](../-state-container/index.md)<[T](index.md)> | ||
|
||
A [StateContainer](../-state-container/index.md) that provides the ability to mutate the wrapped state values. All mutable operations should be considered thread-safe and safe to access concurrently. | ||
|
||
#### See also | ||
|
||
| | | | ||
|---|---| | ||
| [mutableStateContainerOf](../mutable-state-container-of.md) | To create an instance of this interface. | | ||
|
||
## Types | ||
|
||
| Name | Summary | | ||
|---|---| | ||
| [Companion](-companion/index.md) | [common]<br>object [Companion](-companion/index.md) | | ||
|
||
## Functions | ||
|
||
| Name | Summary | | ||
|---|---| | ||
| [change](change.md) | [common]<br>abstract suspend fun [change](change.md)(block: suspend (current: [T](index.md)) -> [T](index.md))<br>Updates the [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md) value to be the value obtained by invoking the provided [block](change.md) function. The [block](change.md) function is invoked within a lock, so subsequent calls to read the contained state values, such as [current](../../../../statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/current.md), are guaranteed to return the same value, as no other mutations can occur until after the function returns and its result is emitted. | | ||
| [change](../change.md) | [common]<br>suspend fun <[T](../change.md)> [MutableStateContainer](index.md)<[T](../change.md)>.[change](../change.md)(value: [T](../change.md))<br>Updates the [StateContainer.current](../-state-container/current.md) value to be the provided [value](../change.md). This is a convenience function that delegates to the [MutableStateContainer.change](change.md) by providing a higher-order function that simply returns the provided [value](../change.md). | | ||
| [reset](reset.md) | [common]<br>abstract suspend fun [reset](reset.md)(initialValue: [T](index.md) = this.initial.value)<br>Resets the state to the provided [initialValue](reset.md). This provides a way to override what the initial value was by providing an [initialValue](reset.md) as a parameter. | | ||
|
||
## Properties | ||
|
||
| Name | Summary | | ||
|---|---| | ||
| [changed](../-state-container/changed.md) | [common]<br>abstract val [changed](../-state-container/changed.md): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)><br>A [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) that determines whether the [current](../-state-container/current.md) value ever changed from the [initial](../-state-container/initial.md) value. Once the [current](../-state-container/current.md) value changes from the [initial](../-state-container/initial.md) value, this should always return a [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) with a value of `true`, even if the [current](../-state-container/current.md) value changed back to the same value of [initial](../-state-container/initial.md), until it is reset. | | ||
| [current](../-state-container/current.md) | [common]<br>abstract val [current](../-state-container/current.md): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[T](index.md)><br>The current [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) for this component. This value can change over time, so subsequent calls to access this property can return different values. | | ||
| [initial](../-state-container/initial.md) | [common]<br>abstract val [initial](../-state-container/initial.md): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[T](index.md)><br>The initial [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) when this component was first created or when it was last reset. This value does not change when the [current](../-state-container/current.md) value changes. However, this value may change depending on the [StateContainer](../-state-container/index.md) implementation. | | ||
| [stream](../-state-container/stream.md) | [common]<br>abstract val [stream](../-state-container/stream.md): StateFlow<[T](index.md)><br>A Flow of changes that occur to the [current](../-state-container/current.md) value over time. Whenever the [current](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value changes, that new value is emitted through this Flow. This is a StateFlow which means that it can retain the last emitted value which can be accessed like so: `container.stream.value`. | |
30 changes: 30 additions & 0 deletions
30
...re/statex-core/com.mooncloak.kodetools.statex/-mutable-state-container/reset.md
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,30 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[MutableStateContainer](index.md)/[reset](reset.md) | ||
|
||
# reset | ||
|
||
[common]\ | ||
abstract suspend fun [reset](reset.md)(initialValue: [T](index.md) = this.initial.value) | ||
|
||
Resets the state to the provided [initialValue](reset.md). This provides a way to override what the initial value was by providing an [initialValue](reset.md) as a parameter. | ||
|
||
!Note This is different from invoking the [change](change.md) function as it sets all the values back to their initial state, as if the initial value was the provided [initialValue](reset.md). | ||
|
||
!Note All write operations for a [MutableStateContainer](index.md) are safe to access concurrently. This means that if another mutation is currently running while this function is invoked, then this function will suspend until that function has finished. | ||
|
||
## Example Usage | ||
|
||
```kotlin | ||
// Reset back to the initial value when creating this StateContainer instance. | ||
stateContainer.reset() | ||
|
||
// Reset to a new initial value. | ||
stateContainer.reset(initialValue = newInitialValue) | ||
``` | ||
|
||
#### Parameters | ||
|
||
common | ||
|
||
| | | | ||
|---|---| | ||
| initialValue | The value to set as the initial value. Defaults to [StateContainer.initial](../-state-container/initial.md). | |
19 changes: 19 additions & 0 deletions
19
...x-core/statex-core/com.mooncloak.kodetools.statex/-platform-view-model/index.md
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,19 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[PlatformViewModel](index.md) | ||
|
||
# PlatformViewModel | ||
|
||
expect abstract class [PlatformViewModel](index.md)actual abstract class [PlatformViewModel](index.md) : [ViewModel](https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModel.html)actual abstract class [PlatformViewModel](index.md)actual abstract class [PlatformViewModel](index.md)actual abstract class [PlatformViewModel](index.md)actual abstract class [PlatformViewModel](index.md) | ||
|
||
An internal base "ViewModel" component that delegates to any such platform-specific component. This allows the [ViewModel](../-view-model/index.md) component from this library to extend from and inherit any platform-specific ViewModel functionality. For example, on Android, there is the `androidx.lifecycle.ViewModel` class which provides functionality useful for Android development. Therefore, the Android implementation of this component inherits from the `androidx.lifecycle.ViewModel` component. | ||
|
||
#### Inheritors | ||
|
||
| | | ||
|---| | ||
| [ViewModel](../-view-model/index.md) | | ||
|
||
## Functions | ||
|
||
| Name | Summary | | ||
|---|---| | ||
| [addCloseable](index.md#264516373%2FFunctions%2F596112941) | [android]<br>open fun [addCloseable](index.md#264516373%2FFunctions%2F596112941)(@[NonNull](https://developer.android.com/reference/kotlin/androidx/annotation/NonNull.html)p0: [Closeable](https://developer.android.com/reference/kotlin/java/io/Closeable.html)) | |
6 changes: 6 additions & 0 deletions
6
...statex-core/com.mooncloak.kodetools.statex/-state-container/-companion/index.md
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,6 @@ | ||
//[statex-core](../../../../index.md)/[com.mooncloak.kodetools.statex](../../index.md)/[StateContainer](../index.md)/[Companion](index.md) | ||
|
||
# Companion | ||
|
||
[common]\ | ||
object [Companion](index.md) |
20 changes: 20 additions & 0 deletions
20
...tex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/changed.md
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 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[StateContainer](index.md)/[changed](changed.md) | ||
|
||
# changed | ||
|
||
[common]\ | ||
abstract val [changed](changed.md): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)> | ||
|
||
A [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) that determines whether the [current](current.md) value ever changed from the [initial](initial.md) value. Once the [current](current.md) value changes from the [initial](initial.md) value, this should always return a [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) with a value of `true`, even if the [current](current.md) value changed back to the same value of [initial](initial.md), until it is reset. | ||
|
||
## Example Usage | ||
|
||
```kotlin | ||
stateContainer.changed.value | ||
``` | ||
|
||
#### See also | ||
|
||
| | | | ||
|---|---| | ||
| [MutableStateContainer.reset](../-mutable-state-container/reset.md) | To see how to reset a [MutableStateContainer](../-mutable-state-container/index.md) back to its initial state. | |
23 changes: 23 additions & 0 deletions
23
...tex-core/statex-core/com.mooncloak.kodetools.statex/-state-container/current.md
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,23 @@ | ||
//[statex-core](../../../index.md)/[com.mooncloak.kodetools.statex](../index.md)/[StateContainer](index.md)/[current](current.md) | ||
|
||
# current | ||
|
||
[common]\ | ||
abstract val [current](current.md): [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html)<[T](index.md)> | ||
|
||
The current [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) for this component. This value can change over time, so subsequent calls to access this property can return different values. | ||
|
||
!Note That this is a Compose [State](https://developer.android.com/reference/kotlin/androidx/compose/runtime/State.html) value and will trigger recompositions of `@Composable` functions when used in the context of a `@Composable` function. | ||
|
||
## Example Usage | ||
|
||
```kotlin | ||
stateContainer.current.value | ||
``` | ||
|
||
#### See also | ||
|
||
| | | | ||
|---|---| | ||
| [MutableStateContainer.change](../-mutable-state-container/change.md) | For a way of changing this value. | | ||
| [MutableStateContainer.reset](../-mutable-state-container/reset.md) | For a way of resetting this value. | |
Oops, something went wrong.