Created
October 22, 2012 20:31
-
-
Save thefringeninja/3933964 to your computer and use it in GitHub Desktop.
This file contains 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 Item { | |
public ReactiveCommand Remove{ get; protected set; } | |
} | |
public class MyModel { | |
public ObservableCollection<Item> Items { get; protected set; } | |
} | |
MyModel model = new MyModel{Items = { new Item(), new Item() }}; | |
this.Items = model.Items.CreateDerivedCollection(projectFunction); | |
// how to wire existing Item's RemoveIt command here? | |
// I had been enumerating the initial collection but it was ugly | |
// and was hoping for a better way. | |
// | |
// this.Items.ForEach(item => item.RemoveIt.Subscribe(_ => Items.Remove(item))); | |
this.WhenAny(x => x.Items, x => x.Value) | |
.Subscribe(c => c.ItemsAdded.Subscribe(item => item.RemoveIt.Subscribe(_ => Items.Remove(item)))); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment