Live Cells C++
Reactive Programming for C++
Loading...
Searching...
No Matches
live_cells::Cell Concept Reference

Defines the cell protocol. More...

#include <types.hpp>

Concept definition

template<typename T>
concept live_cells::Cell = requires(const T &o) {
{ o.add_observer(observer::ref()) };
{ o.value() } -> std::same_as<typename T::value_type>;
{ o() } -> std::same_as<typename T::value_type>;
{ o.key() } -> std::same_as<key_ref>;
}
A computed cell which determines its argument cells at runtime.
Definition dynamic_compute_cell.hpp:153
std::shared_ptr< observer > ref
Shared pointer to an observer.
Definition types.hpp:37
void remove_observer(observer::ref o) const
Remove an observer from the cell.
Definition stateful_cell.hpp:92
Defines the cell protocol.
Definition types.hpp:128

Detailed Description

Defines the cell protocol.

Cells must define the following types:

  • value_type

    The type of value held by the observable.

Cell types must the following methods:

  • void add_observer(observer::ref o) const;

    Add observer o to this cell.

  • void remove_observer(observer::ref o) const;

    Remove observer o from this cell.

    Implementations should only remove o after this method is called the same number of times as add_observer() was called with the same observer o.

  • value_type value() const;

    Return the value held by the observable.

  • value_type operator()() const;

    Track this cell as a dependency and return its value.

  • key_ref key() const;

    Return a key that uniquely identifies the observable.