Method ItemCell
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Collections.dll
ItemCell<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, TKey)
A cell that follows the two parts of one item together. It has no value while the store does not have the key.
public static Cell<Maybe<Item<TIdentity, TState>>> ItemCell<TKey, TIdentity, TState>(this ReactiveCollection<TKey, TIdentity, TState> collection, TKey key) where TKey : notnull where TIdentity : notnull
Parameters
collectionReactiveCollection<TKey, TIdentity, TState>The collection or view to monitor.
keyTKeyThe key to monitor.
Returns
Type Parameters
TKeyThe type of the keys.
TIdentityThe type of the immutable part of an item.
TStateThe type of the mutable part of an item.
Remarks
Use this for a value that reads the identity and the state together. It gives one optional value, and not two. Thus, no code must answer for an identity with no state, or for a state with no identity. The store cannot give those two conditions.
This sends a value at each edit to the state of its key, as StateCell<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, TKey) does. Where one binding reads the identity and a different binding reads the state, use the two cells and not this one. IdentityCell<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, TKey) sleeps through an edit to the state, and a value from this one does not.
The cache, the answer for a view, and the behavior at a missing key are those of StateCell<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, TKey).