ExRatatui.Subscription (ExRatatui v0.7.1)

Copy Markdown View Source

Subscriptions represent ongoing or delayed self-messages owned by an app.

The server reconciles subscriptions after each state transition, diffing by stable id so applications can declare timers without manually managing Process.send_after/3 references.

Available subscription constructors:

  • interval/3 — repeated self-message at a fixed interval
  • once/3 — one-shot self-message delivered once after a delay

Reducer apps declare subscriptions by implementing subscriptions/1.

Summary

Functions

Declares a repeating self-message subscription.

Returns an empty subscription list.

Declares a one-shot self-message subscription.

Types

kind()

@type kind() :: :interval | :once

t()

@type t() :: %ExRatatui.Subscription{
  id: term(),
  interval_ms: pos_integer(),
  kind: kind(),
  message: term()
}

Functions

interval(id, interval_ms, message)

@spec interval(term(), pos_integer(), term()) :: t()

Declares a repeating self-message subscription.

id should be stable across renders for the same logical subscription so the runtime can keep it armed instead of cancelling and recreating it.

none()

@spec none() :: []

Returns an empty subscription list.

Useful when subscriptions/1 or helper functions want to return an explicit "no subscriptions" value.

once(id, interval_ms, message)

@spec once(term(), pos_integer(), term()) :: t()

Declares a one-shot self-message subscription.

Like interval/3, id is used for reconciliation. Once the message fires, the subscription stays inactive until your app returns it again.