Method StateCell
- Namespace
- SodaFlow.Collections
- Assembly
- SodaFlow.Collections.dll
StateCell<TKey, TIdentity, TState>(ReactiveCollection<TKey, TIdentity, TState>, TKey)
A cell that follows the mutable part of one item. It has no value while the store does not have the key.
public static Cell<Maybe<TState>> StateCell<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
The cost is low, thus code can make one for each bound view. It filters on one hash lookup and does not read the other items. A weak cache holds one for each key, thus N observers of one key share a node, and two views of the same root give the same cell.
The key can be missing now. A removal sends no value, and a subsequent add with the same key sends a value again. Thus, a view that binds to a key can continue after the item.
This answers for the store and not for the members of a view. A read of a filtered view for a key that its filter removed gives the state of that item. KeysCell answers for the members.