Skip to content

Commit 0218297

Browse files
committed
feat: Add observability events
1 parent 78cc483 commit 0218297

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

SimpleDataGrid/Pagination/PagedCollection.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,21 @@ public int PageSize
4949
/// </summary>
5050
public event EventHandler? FilterChanged;
5151

52+
/// <summary>
53+
/// Occurs when the current page changes.
54+
/// </summary>
55+
public event EventHandler? PageChanged;
56+
57+
/// <summary>
58+
/// Occurs when the source collection changes.
59+
/// </summary>
60+
public event EventHandler? SourceChanged;
61+
62+
/// <summary>
63+
/// Occurs when the search criteria changes.
64+
/// </summary>
65+
public event EventHandler? SearchChanged;
66+
5267
/// <summary>
5368
/// Initializes a new instance of the <see cref="PagedCollection{T}"/> class.
5469
/// </summary>
@@ -67,6 +82,7 @@ public void SetSource(IReadOnlyList<T> items)
6782
{
6883
_source = items ?? throw new ArgumentNullException(nameof(items));
6984
ApplyFiltering();
85+
SourceChanged?.Invoke(this, EventArgs.Empty);
7086
}
7187

7288
/// <summary>
@@ -132,6 +148,7 @@ public void SetSearch(Func<T, string> selector, string? term, bool useWildcards
132148
_searchTerm = term;
133149
_useWildcards = useWildcards;
134150
ApplyFiltering();
151+
SearchChanged?.Invoke(this, EventArgs.Empty);
135152
}
136153

137154
/// <summary>
@@ -253,6 +270,7 @@ public void NextPage()
253270
OnPropertyChanged(nameof(CurrentPage));
254271
OnPropertyChanged(nameof(HasNext));
255272
OnPropertyChanged(nameof(HasPrevious));
273+
PageChanged?.Invoke(this, EventArgs.Empty);
256274
}
257275
}
258276

@@ -268,6 +286,7 @@ public void PreviousPage()
268286
OnPropertyChanged(nameof(CurrentPage));
269287
OnPropertyChanged(nameof(HasNext));
270288
OnPropertyChanged(nameof(HasPrevious));
289+
PageChanged?.Invoke(this, EventArgs.Empty);
271290
}
272291
}
273292

@@ -285,6 +304,7 @@ public void GoToPage(int page)
285304
OnPropertyChanged(nameof(CurrentPage));
286305
OnPropertyChanged(nameof(HasNext));
287306
OnPropertyChanged(nameof(HasPrevious));
307+
PageChanged?.Invoke(this, EventArgs.Empty);
288308
}
289309
}
290310

0 commit comments

Comments
 (0)