atomWithParent<A, Parent extends Atom> function
AtomWithParent<A, Parent>
atomWithParent<A, Parent extends Atom>(
- Parent parent,
- A create(
- AtomContext<
A> get, - Parent parent
- AtomContext<
Create an Atom that is linked to a parent Atom.
Can be used to tie a state to the thing that generates it.
I.e the parent could be a ValueNotifier<T>
and the child would be the
value it emits, of type T
. It would be represented by
AtomWithParent<T, Atom<ValueNotifier<T>>>.
See futureAtom and streamAtom for examples.
Implementation
AtomWithParent<A, Parent> atomWithParent<A, Parent extends Atom>(
Parent parent,
A Function(AtomContext<A> get, Parent parent) create,
) =>
AtomWithParent(parent, create);