public ObservableGroup(ObservableGroupToken token, IEnumerable <IEntity> initialEntities, INotifyingEntityCollection notifyingCollection) { Token = token; NotifyingCollection = notifyingCollection; _onEntityAdded = new Subject <IEntity>(); _onEntityRemoved = new Subject <IEntity>(); _onEntityRemoving = new Subject <IEntity>(); Subscriptions = new List <IDisposable>(); CachedEntities = initialEntities.Where(x => Token.LookupGroup.Matches(x)).ToDictionary(x => x.Id, x => x); MonitorEntityChanges(); }
private void MonitorEntityChanges(INotifyingEntityCollection notifyingCollection) { notifyingCollection.EntityAdded .Subscribe(OnEntityAddedToCollection) .AddTo(Subscriptions); notifyingCollection.EntityRemoved .Subscribe(OnEntityRemovedFromCollection) .AddTo(Subscriptions); notifyingCollection.EntityComponentsAdded .Subscribe(OnEntityComponentAdded) .AddTo(Subscriptions); notifyingCollection.EntityComponentsRemoving .Subscribe(OnEntityComponentRemoving) .AddTo(Subscriptions); notifyingCollection.EntityComponentsRemoved .Subscribe(OnEntityComponentRemoved) .AddTo(Subscriptions); }