std1.0.0-beta-7 SafeC docs

std :: reactive::signal

Struct std::Signal

#include <std/reactive/signal.h> source

generic<T> struct Signal {
    T value;
    unsigned long version;
    struct Vec<struct SignalSub> subs;
}

Fields

§T valuesource
§unsigned long versionsource

bumped on every set()

§struct Vec<struct SignalSub> subssource

Methods

§static struct Signal<T> new(T val)source · definition

holds val, version 0, no subscribers

§T get() constsource · definition

A copy of the value. For a value that owns something (a String), a copy would share it: use get_ref() (or clone what it refers to) instead.

§&T get_ref()source · definition

in-place access; call notify() after mutating

§void set(T val)source · definition

stores val, bumps version, notifies

§unsigned long get_version() constsource · definition
§int changed(&unsigned long last_seen) constsource · definition

1 (and updates *last_seen) if the version moved since *last_seen — polling-style change detection instead of signal_subscribe()'s push style.

§void notify()source · definition

calls every subscriber in registration order

§void unsubscribe_all()source · definition
§void drop()source · definition

frees the subscriber list

§void free() consumesource · definition

= drop()