@umbraco-cms/backoffice
    Preparing search index...

    Function pushToUniqueArray

    • Function

      pushToUniqueArray

      Type Parameters

      • T

      Parameters

      • data: T[]

        An array of objects.

      • entry: T

        The object to insert or replace with.

      • getUniqueMethod: (entry: T) => unknown

        Method to get the unique value of an entry.

      Returns T[]

      • Append or replaces an item of an Array.

      Example: Example append new entry for a Array. Where the key is unique and the item will be updated if matched with existing.

      const entry = {key: 'myKey', value: 'myValue'};
      const newDataSet = pushToUniqueArray([], entry, x => x.key === key);
      myState.setValue(newDataSet);
    MMNEPVFCICPMFPCPTTAAATR