GitHub

AtomContext

API reference for AtomContext.

What an atom's read gets. Calling it (get(atom)) or get.get(atom) reads atom and makes the reader depend on it; once reads without depending. Once the build it belongs to is replaced, the context only reads (updates and subscriptions are ignored).

Attributes

AttributeTypeDescription
registryAtomRegistryService

Functions

__call__

__call__[A](atom) -> A
ParameterTypeDescription
atomAtom[A]

Returns A

def __call__[A](self, atom: Atom[A], /) -> A: ...

get

get[A](atom) -> A
ParameterTypeDescription
atomAtom[A]

Returns A

def get[A](self, atom: Atom[A], /) -> A: ...

once

once[A](atom) -> A
ParameterTypeDescription
atomAtom[A]

Returns A

def once[A](self, atom: Atom[A], /) -> A: ...

result

result[A, E](atom, /, *, suspend_on_waiting=False) -> Effect[A, E]

The atom's value as an effect (depending on it): its success or failure, waiting while it is Initial (or waiting, with suspend_on_waiting).

ParameterTypeDescription
atomAtom[AsyncResult[A, E]]
suspend_on_waitingbool = False

Returns Effect[A, E]

def result[A, E](
    self, atom: Atom[AsyncResult[A, E]], /, *, suspend_on_waiting: bool = False
) -> Effect[A, E]:
    """The atom's value as an effect (depending on it): its success or
    failure, waiting while it is ``Initial`` (or waiting, with
    ``suspend_on_waiting``)."""
    ...

result_once

result_once[A, E](atom, /, *, suspend_on_waiting=False) -> Effect[A, E]
ParameterTypeDescription
atomAtom[AsyncResult[A, E]]
suspend_on_waitingbool = False

Returns Effect[A, E]

def result_once[A, E](
    self, atom: Atom[AsyncResult[A, E]], /, *, suspend_on_waiting: bool = False
) -> Effect[A, E]: ...

some

some[A](atom) -> Effect[A]
ParameterTypeDescription
atomAtom[Option[A]]

Returns Effect[A]

def some[A](self, atom: Atom[Option[A]], /) -> Effect[A]: ...

some_once

some_once[A](atom) -> Effect[A]
ParameterTypeDescription
atomAtom[Option[A]]

Returns Effect[A]

def some_once[A](self, atom: Atom[Option[A]], /) -> Effect[A]: ...

add_finalizer

add_finalizer(f) -> None

Run f when this build is replaced or the atom removed.

ParameterTypeDescription
fCallable[[], None]
def add_finalizer(self, f: Callable[[], None], /) -> None:
    """Run ``f`` when this build is replaced or the atom removed."""
    ...

mount

mount(atom) -> None

Keep atom mounted while this build lasts.

ParameterTypeDescription
atomAtom[Any]
def mount(self, atom: Atom[Any], /) -> None:
    """Keep ``atom`` mounted while this build lasts."""
    ...

refresh

refresh(atom) -> None
ParameterTypeDescription
atomAtom[Any]
def refresh(self, atom: Atom[Any], /) -> None: ...

refresh_self

refresh_self() -> None
def refresh_self(self) -> None: ...

self

self() -> Option[Any]

This atom's current value, if it has one.

Returns Option[Any]

def self(self) -> Option[Any]:
    """This atom's current value, if it has one."""
    ...

set_self

set_self(value) -> None

Replace this atom's value (from a callback or a fiber).

ParameterTypeDescription
valueAny
def set_self(self, value: Any, /) -> None:
    """Replace this atom's value (from a callback or a fiber)."""
    ...

set

set[W](atom, value) -> None
ParameterTypeDescription
atomWritable[Any, W]
valueW
def set[W](self, atom: Writable[Any, W], value: W, /) -> None: ...

set_result

set_result[A, E, W](atom, value) -> Effect[A, E]
ParameterTypeDescription
atomWritable[AsyncResult[A, E], W]
valueW

Returns Effect[A, E]

def set_result[A, E, W](
    self, atom: Writable[AsyncResult[A, E], W], value: W, /
) -> Effect[A, E]: ...

stream

stream[A](atom, /, *, without_initial_value=False) -> Stream[A]
ParameterTypeDescription
atomAtom[A]
without_initial_valuebool = False

Returns Stream[A]

def stream[A](self, atom: Atom[A], /, *, without_initial_value: bool = False) -> Stream[A]: ...

stream_result

stream_result[A, E](atom, /, *, without_initial_value=False) -> Stream[A, E]
ParameterTypeDescription
atomAtom[AsyncResult[A, E]]
without_initial_valuebool = False

Returns Stream[A, E]

def stream_result[A, E](
    self, atom: Atom[AsyncResult[A, E]], /, *, without_initial_value: bool = False
) -> Stream[A, E]: ...

subscribe

subscribe[A](atom, f, /, *, immediate=False) -> None
ParameterTypeDescription
atomAtom[A]
fCallable[[A], None]
immediatebool = False
def subscribe[A](
    self, atom: Atom[A], f: Callable[[A], None], /, *, immediate: bool = False
) -> None: ...