Skip to content

ReadOnlyObservableCollection.reduce

Andrei Fangli edited this page Sep 3, 2023 · 2 revisions

Aggregates the collection to a single item.

This is a public method.

public reduce(callbackfn: (previousValue: TItem, currentItem: TItem, currentIndex: number, array: readonly TItem[]) => TItem): TItem

Parameters

  • callbackfn: Function, the callback that aggregates two items at a time.

    Parameters:

    • previousValue: TItem, the current result value, returned from a previous invocation of the callback.
    • currentItem: TItem, the item being processed.
    • currentIndex: Number, the index of the item being processed.
    • collection: IReadOnlyObservableCollection<TItem>, the collection being iterated.

    Returns: TItem

    Returns the result of the aggregation between the previousValue and currentItem.

Returns: TItem

Returns a single aggregated item.

See


Aggregates the collection to a single value.

This is a public method.

public reduce<TResult>(callbackfn: (previousValue: TResult, currentItem: TItem, currentIndex: number, array: readonly TItem[]) => TResult, initialValue: TResult): TResult

Template Parameters

  • TResult: the type of value to aggregate the collection to.

Parameters

  • callbackfn: Function, the callback that aggregates one item and the previous value at a time.

    Parameters:

    • previousValue: TResult, the current result value, returned from a previous invocation of the callback.
    • currentItem: TItem, the item being processed.
    • currentIndex: Number, the index of the item being processed.
    • collection: IReadOnlyObservableCollection<TItem>, the collection being iterated.

    Returns: TResult

    Returns the result of the aggregation between the previousValue and currentItem.
  • initialValue: TResult, the initial value when aggregating the collection.

Returns: TResult

Returns the value containing the aggregated collection.

See

Clone this wiki locally