atom

@JvmName(name = "atomWithParcelable")
inline fun <T : Parcelable> atom(initialValue: T, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<T>

Creates an Atom using AtomSaverKey for Parcelable.

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.


@JvmName(name = "atomWithParcelableArrayList")
inline fun <T : Parcelable> atom(initialValue: ArrayList<T>, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<ArrayList<T>>

Creates an Atom using AtomSaverKey for ArrayList with Parcelable.

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.


@JvmName(name = "atomWithParcelableArray")
inline fun <T : Parcelable> atom(initialValue: Array<T>, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<Array<T>>

Creates an Atom using AtomSaverKey for Array with Parcelable.

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.


@JvmName(name = "atomWithSerializable")
inline fun <T : Serializable> atom(initialValue: T, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<T>

Creates an Atom using AtomSaverKey for Serializable.

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.

fun <T> atom(initialValue: T, saver: AtomSaver<T>? = null, scope: AtomScope? = null): Atom<T>

Creates an Atom.

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saver

The saver to be used to save and restore the value.

scope

The scope to be used to manage the value.


inline fun <T> atom(initialValue: T, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<T>

Creates an Atom using AtomSaverKey.

Automatically selects an AtomSaver for the Type if it matches any of the following. The saverKey is used as a key for the AtomSaver.

| Type        | AtomSaver     |
| :---------- | :-------------|
| String      | stringSaver   |
| Boolean     | booleanSaver  |
| Int         | intSaver      |
| Long        | longSaver     |
| Double      | doubleSaver   |
| Float       | floatSaver    |
| Char        | charSaver     |
| Short       | shortSaver    |
| Byte        | byteSaver     |

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.


@JvmName(name = "atomWithArrayList")
inline fun <T> atom(initialValue: ArrayList<T>, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<ArrayList<T>>

Creates an Atom using AtomSaverKey for ArrayList.

Automatically selects an AtomSaver for the Type if it matches any of the following. The saverKey is used as a key for the AtomSaver.

| Type            | AtomSaver                     |
| :-------------- | :---------------------------- |
| String          | stringArrayListSaver          |
| Int             | integerArrayListSaver         |
| CharSequence    | charSequenceArrayListSaver    |

Return

The created Atom.

Parameters

T

The type of the value to be stored.

initialValue

The initial value to be stored.

saverKey

The key to be used to save and restore the value.

scope

The scope to be used to manage the value.


@JvmName(name = "atomWithBooleanArray")
inline fun atom(initialValue: BooleanArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<BooleanArray>
@JvmName(name = "atomWithByteArray")
inline fun atom(initialValue: ByteArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<ByteArray>
@JvmName(name = "atomWithShortArray")
inline fun atom(initialValue: ShortArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<ShortArray>
@JvmName(name = "atomWithCharArray")
inline fun atom(initialValue: CharArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<CharArray>
@JvmName(name = "atomWithIntArray")
inline fun atom(initialValue: IntArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<IntArray>
@JvmName(name = "atomWithLongArray")
inline fun atom(initialValue: LongArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<LongArray>
@JvmName(name = "atomWithFloatArray")
inline fun atom(initialValue: FloatArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<FloatArray>
@JvmName(name = "atomWithDoubleArray")
inline fun atom(initialValue: DoubleArray, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<DoubleArray>
@JvmName(name = "atomWithArray")
inline fun <T> atom(initialValue: Array<T>, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<Array<T>>
@JvmName(name = "atomWithBundle")
inline fun atom(initialValue: Bundle, saverKey: AtomSaverKey, scope: AtomScope? = null): Atom<Bundle>


fun <T> atom(block: AtomSelector.() -> T): AtomRef<T>

Creates an AtomRef with the specified block function.

Usage:

val counter1Atom = atom(0)
val counter2Atom = atom(0)
val sumAtom = atom {
get(counter1Atom) + get(counter2Atom)
}

Return

The created AtomRef.

Parameters

T

The type of the value to be retrieved.

block

The function that retrieves the value derived from one or more Atom references key.