auto sub = new SubjectObject!int; auto group = sub.groupBy!(n => n % 10); auto tester = new CounterObserver!(typeof(group).ElementType); auto disposable = group.subscribe(tester); sub.put(0); assert(tester.putCount == 1); assert(tester.lastValue.key == 0); sub.put(10); assert(tester.putCount == 1);
auto sub = new SubjectObject!string; auto group = sub.groupBy!(text => text); auto tester = new CounterObserver!(typeof(group).ElementType); auto disposable = group.subscribe(tester); sub.put("A"); assert(tester.putCount == 1); assert(tester.lastValue.key == "A"); sub.put("B"); assert(tester.putCount == 2); assert(tester.lastValue.key == "B"); sub.put("XXX"); assert(tester.putCount == 3); assert(tester.lastValue.key == "XXX");