Created
June 20, 2021 13:37
-
-
Save rdelrosario/fa60efd4a70d67ff52ade4c2ed3fbb1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ItemManager : IItemManager | |
{ | |
public ItemManager() | |
{ | |
ItemChanges = _itemsCache.Connect() | |
.RefCount(); | |
} | |
public Optional<Item> Get(string id) => _itemsCache.Lookup(id); | |
public IObservable<IChangeSet<Item, string>> ItemChanges { get; } | |
public void AddOrUpdate(Item item) => _itemsCache.AddOrUpdate(item); | |
public void Remove(Item item) => _itemsCache.Remove(item); | |
private SourceCache<Item, string> _itemsCache = new SourceCache<Item, string>(item => item.Id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment