Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/DynamicData/Cache/Internal/AnonymousObservableCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Roland Pheasant licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reactive.Disposables;
using DynamicData.Kernel;

namespace DynamicData.Cache.Internal;
Expand All @@ -14,6 +13,7 @@ internal sealed class AnonymousObservableCache<TObject, TKey> : IObservableCache
where TKey : notnull
{
private readonly IObservableCache<TObject, TKey> _cache;
private readonly IDisposable _cleanUp;

public AnonymousObservableCache(IObservable<IChangeSet<TObject, TKey>> source)
{
Expand All @@ -23,9 +23,16 @@ public AnonymousObservableCache(IObservable<IChangeSet<TObject, TKey>> source)
}

_cache = new ObservableCache<TObject, TKey>(source);

_cleanUp = _cache;
}

public AnonymousObservableCache(IObservableCache<TObject, TKey> cache) => _cache = cache ?? throw new ArgumentNullException(nameof(cache));
public AnonymousObservableCache(IObservableCache<TObject, TKey> cache)
{
_cache = cache ?? throw new ArgumentNullException(nameof(cache));

_cleanUp = Disposable.Empty;
}

public int Count => _cache.Count;

Expand All @@ -40,11 +47,11 @@ public AnonymousObservableCache(IObservable<IChangeSet<TObject, TKey>> source)
public IObservable<IChangeSet<TObject, TKey>> Connect(Func<TObject, bool>? predicate = null, bool suppressEmptyChangeSets = true)
=> _cache.Connect(predicate, suppressEmptyChangeSets);

public void Dispose() => _cache.Dispose();

public Optional<TObject> Lookup(TKey key) => _cache.Lookup(key);

public IObservable<IChangeSet<TObject, TKey>> Preview(Func<TObject, bool>? predicate = null) => _cache.Preview(predicate);

public IObservable<Change<TObject, TKey>> Watch(TKey key) => _cache.Watch(key);

public void Dispose() => _cleanUp.Dispose();
}
13 changes: 10 additions & 3 deletions src/DynamicData/List/Internal/AnonymousObservableList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
// See the LICENSE file in the project root for full license information.

using System.Diagnostics;
using System.Reactive.Disposables;

namespace DynamicData.List.Internal;

[DebuggerDisplay("AnonymousObservableList<{typeof(T).Name}> ({Count} Items)")]
internal sealed class AnonymousObservableList<T> : IObservableList<T>
{
private readonly ISourceList<T> _sourceList;
private readonly IDisposable _cleanUp;

public AnonymousObservableList(IObservable<IChangeSet<T>> source)
{
Expand All @@ -19,9 +21,14 @@ public AnonymousObservableList(IObservable<IChangeSet<T>> source)
}

_sourceList = new SourceList<T>(source);
_cleanUp = _sourceList;
}

public AnonymousObservableList(ISourceList<T> sourceList) => _sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList));
public AnonymousObservableList(ISourceList<T> sourceList)
{
_sourceList = sourceList ?? throw new ArgumentNullException(nameof(sourceList));
_cleanUp = Disposable.Empty;
}

public int Count => _sourceList.Count;

Expand All @@ -31,7 +38,7 @@ public AnonymousObservableList(IObservable<IChangeSet<T>> source)

public IObservable<IChangeSet<T>> Connect(Func<T, bool>? predicate = null) => _sourceList.Connect(predicate);

public void Dispose() => _sourceList.Dispose();

public IObservable<IChangeSet<T>> Preview(Func<T, bool>? predicate = null) => _sourceList.Preview(predicate);

public void Dispose() => _cleanUp.Dispose();
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.9",
"version": "7.10",
"publicReleaseRefSpec": [
"^refs/heads/main$", // we release out of master
"^refs/heads/preview/.*", // we release previews
Expand Down