private void RemoveCube(CubeModel cube) { cube.MarkedForRemoval.Value = true; Cubes.Remove(cube); //clean up subscriptions _disposableSubscriptions[cube].Dispose(); _disposableSubscriptions.Remove(cube); }
private void CreateCube() { var cube = new CubeModel(); var compositeDisposableForThisCube = new CompositeDisposable(); _disposableSubscriptions[cube] = compositeDisposableForThisCube; var subscription = cube.Collisions.Where(coll => coll >= NumberOfBouncesBeforeDeletion).Subscribe(x => RemoveCube(cube)) .AddTo(compositeDisposableForThisCube); Cubes.Add(cube); }