Skip to content

Improve collection-based UI #41

@Craftplacer

Description

@Craftplacer

Currently most SCTT components compare UI against data, this is possible to improve, I'd suggest this:

  1. probably make event/interface/class for item changes
  2. for static updates/fetches/pulls, you compare those two collections and call events accordingly

I imagine sharing one base class/interface for either event-based updates or pulling.

Examples of old code

Most of SCTT's current code is like this.

List<Item> newItems = new();
foreach (var item in SomeItemSource)
{
    newItems.Add(item);
    if (!items.Contains(item))
    {
        /* some init here */
        items.Add(item);
    }
}

foreach (var item in items)
{
    if (!newItems.Contains(item))
    {
        _ = items.Remove(item);
        item.Dispose();
    }
}

/* additional processing here */

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions