AvaloniaListExtensions.

ForEachItem<T>(IAvaloniaReadOnlyList<T>, Action<int, T>, Action<int, T>, Action, bool) Method

Summary

Invokes an action for each item in a collection and subsequently each item added or removed from the collection.
Namespace
Avalonia.Collections
Containing Type
AvaloniaListExtensions

Syntax

public static IDisposable ForEachItem<T>(this IAvaloniaReadOnlyList<T> collection, Action<int, T> added, Action<int, T> removed, Action reset, bool weakSubscription = false)

Type Parameters

Name Description
T The type of the collection items.

Parameters

Name Type Description
collection IAvaloniaReadOnlyList<T> The collection.
added Action<int, T> An action called initially for each item in the collection and subsequently for each item added to the collection. The parameters passed are the index in the collection and the item.
removed Action<int, T> An action called for each item removed from the collection. The parameters passed are the index in the collection and the item.
reset Action An action called when the collection is reset. This will be followed by calls to added for each item present in the collection after the reset.
weakSubscription bool Indicates if a weak subscription should be used to track changes to the collection.

Return Value

Type Description
IDisposable A disposable used to terminate the subscription.