AtomRoot

fun AtomRoot(primary: Pair<AtomScope, AtomStore>, vararg others: Pair<AtomScope, AtomStore>, fallbackScope: (Atom<*>) -> AtomScope = { primary.first }, content: @Composable () -> Unit)

Provides multiple AtomStore. You can provide AtomStore corresponding to AtomScope with different lifecycles.

To use the Remember API for handling Atom within content, it is essential to declare AtomRoot somewhere in the parent tree. The scoped store is provided to child components using the Remember API via LocalAtomOwner.

Parameters

primary

The specified AtomScope used preferentially as the default value for fallbackScope.

others

Additional AtomScope and AtomStore pairs with lifecycles different from primary.

fallbackScope

A function that returns an alternate AtomScope if a corresponding AtomScope for an Atom is not found. By default, it returns the AtomScope of primary.

content

The content of the AtomRoot.


fun AtomRoot(store: AtomStore, content: @Composable () -> Unit)

Provides a single AtomStore.

To use the Remember API for handling Atom within content, it is essential to declare AtomRoot somewhere in the parent tree. The store is provided to child components using the Remember API via LocalAtomOwner.

Parameters

store

An instance of AtomStore.

content

The content of the AtomRoot.