Multi level data with IObservableCache #711
Replies: 1 comment
-
Recently, a new operator was added (#736) that allows you to create a merged changeset from a child cache. Something like: class Root
{
public IObservableCache<Parent, ParentKey> Parents { get; }
public IObservableCache<Child, (ParentKey, ChildKey)> AllChildren { get; }
public Root()
{
AllChildren = Parents.Connect().MergeManyChangeSets((parent, parentKey) => p.Children.ChangeKey((childKey, child) => (parentKey, childKey))).AsObservableCache();
}
} That only goes down one level, but you could adapt the pattern to do an arbitrary number. However, the performance might be an issue if you go too deep. However, if you can restructure your code so that Parents/Children/Root are all the same class, then I would use the amazing |
Beta Was this translation helpful? Give feedback.
-
I am looking for a solution to flatten my Tree structure data to a flattened list of observables.
For example
Root
- Parent
- Child
Root has IObservableCache of Parent and each Parent has IObservableCache of Child, I need a collection of the child such that the observable it forms has a composite key (RootKey, ParentKey, ChildKey)
Till now
var transformedobservable = observableParent.TransformMany(parent=> parent.ObservableChildCache.Items.Select(child => new ChildRowModel(child)), x => (x.ParentID, x.ChildID));
But this only observes the changes in parents but does not listen to the child's changes
What if there are more levels in Tree structures, does Dynamic Data have something to merge them logically?
Beta Was this translation helpful? Give feedback.
All reactions