Skip to main content
Module

x/tui/src/signals/mod.ts

🦕 Deno module for creating Terminal User Interfaces
Latest
import * as tui from "https://deno.land/x/tui@2.1.11/src/signals/mod.ts";

Classes

Computed is a type of signal that depends on other signals and updates when any of them changes

Thrown whenever someone tries to directly modify Computed.value

Effect is an container for callback function, which runs every time any of its dependencies get updated.

Flusher tracks

LazyComputed is a type of signal that depends on other signals and updates when any of them changes

  • If time between updates is smaller than given interval it gets delayed
  • If given Flusher instead, it will update after Flusher.flush() gets called
  • Both interval and Flusher might be set at the same time.

LazyEffect is an container for callback function, which runs every time any of its dependencies get updated. When initialized that functions gets ran and all dependencies for it are tracked.

  • If time between updates is smaller than given interval it gets delayed
  • If given Flusher instead, it will update after Flusher.flush() gets called
  • Both interval and Flusher might be set at the same time.

Signal wraps value in a container.

Thrown whenever deepObserve is set and typeof value !== "object"

Functions

Replaces push, pop, sort and replace methods in given array with ones that provide reactivity.

Replaces set, delete and clear methods in given map with ones that provide reactivity.

Watches the object for changes and when they happen propagate method gets called on provided signal.

Replaces add, delete and clear methods in given set with ones that provide reactivity.

Replaces all dependencies with root dependencies to prevent multiple updates caused by the same change.

Asynchronously tracks used signals for provided function

Interfaces

Function that's used to calculate Computed's value

Element which relies on dependencies to function

Element which can be a root Signal, doesn't need to depend on anything

Function that's ran every time Effect.update is called

Element which relies on dependencies to function and updates either after specified interval or when flusher gets flushed

Type describing function that gets called each time signal changes

Type Aliases

Type that defines signal, which doesn't implement any properties that T type has. This is used to enhance DX for typing unions between objects and Signals.