GitHub

API reference for AtomRef.

class AtomRef[A]

A ref that can be set.

Functions

set

set(value) -> Self
ParameterTypeDescription
valueA

Returns Self

def set(self, value: A) -> Self:
    raise NotImplementedError

update

update(f) -> Self
ParameterTypeDescription
fCallable[[A], A]

Returns Self

def update(self, f: Callable[[A], A]) -> Self:
    return self.set(f(self.value))

prop

prop(key) -> AtomRef[Any]

A ref of one field of this ref's value; setting it sets this ref to a copy with that field replaced.

ParameterTypeDescription
keyAny

Returns AtomRef[Any]

def prop(self, key: Any) -> AtomRef[Any]:
    """A ref of one field of this ref's value; setting it sets this
    ref to a copy with that field replaced."""
    return _PropRef(self, key)

subscribe

subscribe(f) -> Callable[[], None]

Call f with each new value; returns the unsubscribe.

ParameterTypeDescription
fCallable[[A], None]

Returns Callable[[], None]

def subscribe(self, f: Callable[[A], None]) -> Callable[[], None]:
    """Call ``f`` with each new value; returns the unsubscribe."""
    raise NotImplementedError

map

map[B](f) -> ReadonlyRef[B]

A ref of f of this one's value, notifying when it changes.

ParameterTypeDescription
fCallable[[A], B]

Returns ReadonlyRef[B]

def map[B](self, f: Callable[[A], B]) -> ReadonlyRef[B]:
    """A ref of ``f`` of this one's value, notifying when it changes."""
    return _MapRef(self, f)