0

How can I merge SourceList and SourceCache<T, TKey>?

Demo Model

internal interface IModel { }
internal class ModelA : IModel
{ }

internal class ModelB : IModel
{ }

Demo instances

var sourceList = new SourceList<IModel>();
var sourceCache = new SourceCache<IModel, int>(m => m.GetHashCode());

Not compiling attempt to merge

sourceList.Connect().Merge(sourceCache.Connect()); // does not compile
sa.he
  • 1,391
  • 12
  • 25
  • I'm new to Rx. This compiles: `sourceList.Connect().Merge(sourceCache.Connect().ToListObservable());` but quite frankly no idea if this corresponds to what you're trying to do. You may also need this: `using System.Reactive.Linq;`. If this is not what you're looking for please let me know and I'll delete this comment. – evilmandarine Sep 09 '21 at 16:48
  • `ToListObservable()` does not return an instance that implements `IObservable>`. This means, I cannot continue with any extension methods of `DynamicData` (e.g. `Filter` or `Bind`). – sa.he Sep 10 '21 at 05:43
  • 1
    How about this: `var merged = sourceList.Connect().Merge(sourceCache.Connect().RemoveKey());` ? This apparently *Removes the key from each change. This changes the change set from a cache change set to a list changeset* – evilmandarine Sep 10 '21 at 08:12
  • `RemoveKey` seems to be the solution (y) – sa.he Sep 15 '21 at 12:45

0 Answers0