reactive_signal/channel

Types

A variable that can be subscribed

pub opaque type Channel(s)

Functions

pub fn modify(channel: Channel(a), f: fn(a) -> a) -> a

Apply function to channel value

pub fn new(initial_value: a) -> Channel(a)

Create a new channel

pub fn subscribe(
  channel: Channel(a),
  new_subscriber: fn(a) -> Nil,
) -> Nil

Subscribe to a channel Subscriber is start as a new process, and exit when the next value is published, or parent process is exit.

pub fn subscribe_from_subject(
  channel: Channel(a),
  subscriber_subject: Subject(a),
) -> Nil

Subscribe to a channel by Subject. Subject will receive messages when the channel value is updated.

pub fn subscribe_with_wait_next(
  channel: Channel(a),
  new_subscriber: fn(a, fn() -> Nil) -> Nil,
) -> Nil

Subscribe to a channel Subscriber is start as a new process, and exit when the next value is published, or parent process is exit.

pub fn try_modify(
  channel: Channel(a),
  f: fn(a) -> a,
) -> Result(a, CallError(a))

Apply function to channel value safely

pub fn try_write(
  channel: Channel(a),
  s: a,
) -> Result(Nil, CallError(a))

Write value to channel safely

pub fn write(channel: Channel(a), s: a) -> Nil

Write value to channel

Search Document