cytoplasmic
    Preparing search index...

    Function computed

    • Create a computed cell. Do not use cell.value inside the computation, always us of(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: (of: DerefFunction) => T

        A function that can unwrap cells using of(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(of => of(a) + of(b));
      const d = zipWith([a, b], (a, b) => a + b);