一键导入
uno-mvux-liststate
Create and use IListState<T> for mutable reactive collections in MVUX.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create and use IListState<T> for mutable reactive collections in MVUX.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | uno-mvux-liststate |
| description | Create and use IListState<T> for mutable reactive collections in MVUX. |
| when_to_use | Use when adding, removing, or updating items in a collection, managing item selection in a list, two-way binding with collections, synchronizing list changes with services via messaging, or converting a read-only `IListFeed<T>` into a mutable `IListState<T>`. |
| metadata | {"author":"uno-platform","version":"2.3","category":"mvux"} |
Docs lookup: call
uno_platform_docs_search(...)first, thenuno_platform_docs_fetch(sourcePath="…")using thesourcePathfield from a result (a relative.mdpath; add the result'sanchorfor a section). Never pass a URL, a.htmllink, or a hand-built path.
There is no dedicated ListState reference page — it shares documentation with ListFeed and State. Search for:
uno_platform_docs_search("MVUX ListState mutable collection add remove update selection")
Key documentation pages:
external/uno.extensions/doc/Reference/Reactive/listfeed.mdexternal/uno.extensions/doc/Reference/Reactive/state.mdexternal/uno.extensions/doc/Reference/Reactive/in-apps.mdFetch the in-apps reference for practical patterns:
uno_platform_docs_fetch(sourcePath="external/uno.extensions/doc/Reference/Reactive/in-apps.md")
ListState<T>.Empty(this) — starts with no itemsListState.Async(this, asyncFunc) — loads initial data from async source.Selection(...) to track selected itemsSearch for mutation operations:
uno_platform_docs_search("MVUX ListState add remove update items operation")
Key operations: AddAsync, RemoveAllAsync, UpdateAsync, InsertAsync.
If the user needs list updates from service CRUD operations:
uno_platform_docs_search("MVUX messaging EntityMessage ListState observe")
See the uno-mvux-messaging skill for full details.
IListState<T> is mutable — supports add/remove/updateListState<T>.Empty(this) or ListState.Async(this, ...).Selection(state) to connect selection trackingIListFeed<T> insteadAll item types used in IListState<T> MUST support key equality via Uno.Extensions.Equality.IKeyEquatable<T>. This is essential for IListState<T> because mutation operations (UpdateAsync, RemoveAllAsync, selection tracking) rely on key equality to identify which item to target. Without it, MVUX cannot match an updated instance to its original, causing broken updates, lost selection state, and full list re-renders.
For partial record types, key equality is auto-generated when the record has a property named Id or Key:
public partial record TodoItem(Guid Id, string Title, bool IsComplete);
// IKeyEquatable<TodoItem> is generated automatically — Id is the key
Use [Key] attribute when the key property has a different name, or for composite keys:
public partial record OrderLine(
[property: Key] Guid OrderId,
[property: Key] int LineNumber,
string Product,
decimal Price);
Either Uno.Extensions.Equality.KeyAttribute or System.ComponentModel.DataAnnotations.KeyAttribute can be used.
Configure which property names are auto-detected as keys:
[assembly: ImplicitKeyEquality("Id", "Key", "EntityId")]
If auto-generation causes issues on a specific type:
[ImplicitKeys(IsEnabled = false)]
public partial record MyItem(Guid Id, string Name);
partial record (or manually implement IKeyEquatable<T>)KeyEquals returns true when two instances represent the same entity, even if other properties differUpdateAsync uses key equality to find the existing item to replace — without it, the update silently fails or replaces the wrong itemThe function passed to UpdateAsync (and to the item-level updaters) must be pure: derive the new value solely from the current value it receives, with no capture of external/mutable variables and no side effects. MVUX is stateless and lockless and applies the updater against the current cached value, so an updater that depends on anything other than its input is not guaranteed to produce a stable result. Project the value you were given onto a new immutable value (use with expressions on records); never reach outside the lambda for state.
// Correct: pure projection of the current item
await Items.UpdateAsync(item => item with { IsDone = true });
// Wrong: result captures external mutable state
await Items.UpdateAsync(_ => _externalItem);
Create and use commands in MVUX for user interactions.
Create and use IFeed<T> for async data in MVUX.
Display async feed data with FeedView control.
Create and use IListFeed<T> for reactive collections in MVUX.
Use messaging to sync MVUX states with entity changes.
Understand MVUX (Model-View-Update-eXtended) architecture in Uno Platform.