GitHub

CollectorService

API reference for CollectorService.

A mutable list of collected values.

Functions

__init__

__init__() -> None
def __init__(self) -> None:
    self._values: list[object] = []

add_all_unsafe

add_all_unsafe(values) -> None

Adds values to the collection, now.

ParameterTypeDescription
valuesIterable[object]
def add_all_unsafe(self, values: Iterable[object]) -> None:
    """Adds ``values`` to the collection, now."""
    self._values.extend(values)

add_all

add_all(values) -> Effect[None]

Adds values to the collection. Never fails.

ParameterTypeDescription
valuesIterable[object]

Returns Effect[None]

def add_all(self, values: Iterable[object]) -> Effect[None]:
    """Adds ``values`` to the collection. Never fails."""
    return sync(lambda: self.add_all_unsafe(values))

read_unsafe

read_unsafe() -> list[object]

The values collected so far, now: the collector's own list, not a copy.

Returns list[object]

def read_unsafe(self) -> list[object]:
    """The values collected so far, now: the collector's own list, not
    a copy."""
    return self._values

read

read() -> Effect[list[object]]

The values collected so far (the collector's own list). Never fails.

Returns Effect[list[object]]

def read(self) -> Effect[list[object]]:
    """The values collected so far (the collector's own list). Never
    fails."""
    return sync(self.read_unsafe)

clear_unsafe

clear_unsafe() -> list[object]

The values collected so far, leaving the collector empty.

Returns list[object]

def clear_unsafe(self) -> list[object]:
    """The values collected so far, leaving the collector empty."""
    previous, self._values = self._values, []
    return previous

clear

clear() -> Effect[list[object]]

The values collected so far, leaving the collector empty. Never fails.

Returns Effect[list[object]]

def clear(self) -> Effect[list[object]]:
    """The values collected so far, leaving the collector empty. Never
    fails."""
    return sync(self.clear_unsafe)