cytoplasmic
    Preparing search index...

    Function computed

    • Create a computed cell. Do not use cell.value inside the computation, always us get(cell) to unwrap cells to properly track dependencies.

      This is an alternative implementation of $ that doesn't rely on global state.

      Type Parameters

      • T

      Parameters

      • computation: (get: DerefFunction) => T

        A function that can unwrap cells using get(cell) and compute a resulting value.

      Returns Cell<T>

      A cell that computes its value based on the provided computation function.

      In the following example c and d are equivalent:

      const a = cell(1);
      const b = cell(2);
      const c = computed(get => get(a) + get(b));
      const d = zipWith([a, b], (a, b) => a + b);