• Creates a new Collection instance. A Collection is a reactive primitive that holds an array of values. Same as collection but returns a new Collection instance.

    Type Parameters

    • T

    Parameters

    • value: T[]

      The array to observe.

    • Optional options: {
          compareFunction: ((a, b) => boolean);
          name: string;
      }

      Options

      • compareFunction: ((a, b) => boolean)

        A function that compares two values to determine if they are equal.

          • (a, b): boolean
          • Parameters

            Returns boolean

      • name: string

        The name of Collection object.

    Returns T[]

    The observed array

    Example

    const items = collection([1, 2, 3]);

    items.subscribe(() => {
    console.log(items.value);
    });

    items.value.push(4);
    // output: [1, 2, 3, 4]