Skip to content
Nuvyntra Labs

Documentation

Lists and search

ObservableRangeCollection, SnapshotCollection for live inboxes, PagedCollection for catalogs, MvvmSearch, and SearchQuery.CommittedText.

ObservableRangeCollection

AddRange and ReplaceRange raise one CollectionChanged Reset. Do not Add in a loop for mid or large lists (MVVME011). Large lists must also virtualize in CollectionView. After a page is visible, prefer Add / Insert over ReplaceRange on Android BindableLayout — SnapshotCollection + BindableLayout is MVVME012. CollectionBind.AsyncFetch is the RemainingItemsThreshold path when the fetch is async.

var items = new ObservableRangeCollection<Product>();
items.AddRange(page);
items.ReplaceRange(next);

Pagination, snapshots, and search

PagedCollection<T> / DelegatePagedCollection<T> own load-more, refresh, and retry — not a live chat inbox. SnapshotCollection<T> loads once in InitializeAsync; later LoadAsync calls are no-ops unless force is true. After appear, mutate with AddLocal / Insert. CollectionBind.AsyncFetch is the blessed RemainingItemsThreshold path when the fetch is async. Do not pair DelegatePagedCollection with CollectionView RemainingItemsThreshold when the fetch is sync (MVVME013). SearchQuery.Text binds to Entry or MvvmSearch; filter from CommittedText after debounce. Android SearchBar is not required.

public sealed class InboxViewModel : ViewModel
{
    public SnapshotCollection<Conversation> Inbox { get; }
    public SearchQuery Search { get; } = new();

    public InboxViewModel(IInbox catalog)
    {
        Inbox = new SnapshotCollection<Conversation>(
            ct => catalog.ListAsync(Search.CommittedText, ct));
    }

    protected override Task InitializeAsync(CancellationToken cancellationToken) =>
        Inbox.LoadAsync(cancellationToken: cancellationToken);
}

// catalog paging (not a live inbox)
await Products.RefreshAsync(ct);
await Products.LoadMoreAsync(ct);

Discussion

Comment on Plugin.Maui.MVVMExpress. The thread lives on this component's GitHub repository (nuvyntralabs/Plugin.Maui.MVVMExpress). Sign in with GitHub — Giscus uses Discussions, Utterances uses Issues.