Skip to main content
Module

x/tui/mod.ts>LazyComputed

🦕 Deno module for creating Terminal User Interfaces
Latest
class LazyComputed
implements LazyDependant
extends Computed<T>
import { LazyComputed } from "https://deno.land/x/tui@2.1.11/mod.ts";

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.

Examples

Example 1

const multiplicand = new Signal(1);
const multiplier = new Signal(2);
const product = new LazyComputed(() => multiplicand.value * multiplier.value, 16);

console.log(product.value); // 2
await Promise.resolve(); // Dependency tracking is asynchronous read more in `dependency_tracking.ts`

multiplicand.value = 2;
console.log(product.value); // 2
multiplier.value = 7;
console.log(product.value); // 2

setTimeout(() => {
 console.log(product.value); // 14
}, 16)

Constructors

new
LazyComputed(computable: Computable<T>, interval: number)
new
LazyComputed(computable: Computable<T>, flusher: Flusher)
new
LazyComputed(computable: Computable<T>, options: LazyComputedOptions)
new
LazyComputed(computable: Computable<T>, option: LazyComputedOptions | number | Flusher)

Properties

optional
flusher: Flusher
optional
interval: number
lastFired: number
optional
timeout: number