0
private static void TestGroupBy()
{
var rxList = new ReactiveList<int>();
Observable.Merge(rxList.ItemsAdded, rxList.ItemChanged.Select(x => x.Sender)).GroupBy(i => i%3)
.Subscribe(group =>
{
Console.WriteLine(string.Format("--> Group {0} is created", group.Key));
int child = 0;
group.Subscribe(c =>
{
Console.WriteLine(string.Format(" ------> Adding child {0} to Group {1} - ChildCnt: {2}", c, group.Key, ++child));
});
});
Console.WriteLine("Add 1 to 10... ");
rxList.AddRange(new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
Console.WriteLine("Change item 0 to 11, expect to be moved from group 0, to Group 2 ");
rxList[0] = 11;
Console.WriteLine("Remove item at 0, expect the item to be removed from the group ...");
rxList.RemoveAt(0);
}
我在这里有这段代码。如果项目被删除,或者项目被替换为新项目,我希望重新组合。我如何实现这一目标?Rx GroupBy:移除项目或更新exising项目不触发重组
你应该澄清:哪里你ReactiveList从何而来,是什么类型的可观察到的是它? –
您是否可以在问题中包含代码的输出以及期望的输出? – pmbanka