This is related to my other question here . James World presented the solution as follows:
<edit 2:
Question: How to start timers immediately, without waiting for the arrival of the first events? I think the problem is with the root in my question. For this, I planned to send dummy objects with identifiers, which, as I know, should be there. But, as I write in the following, I ran into some other problems. However, I think the solution will be interesting too.
Forward with other interesting pieces! Now, if I would like to group a complex object, such as the next one and a group by key, as follows (will not compile)
var idAlarmStream = idStream .Select(i => new { Id = i, IsTest = true }) .GroupByUntil(key => key.Id, grp => grp.Throttle(alarmInterval(grp.Key))) .SelectMany(grp => grp.IgnoreElements().Concat(Observable.Return(grp.Key)));
then i get in trouble. I cannot change the SelectMany , Concat and Observable.Return to make the query work as before. For example, if I make a request like
var idAlarmStream = idStream .Select(i => new { Id = i, IsTest = true }) .GroupByUntil(key => key.Id, grp => grp.Throttle(alarmInterval(grp.Key))) .SelectMany(grp => grp.IgnoreElements().Concat(Observable.Return(grp.Key.First()))) .Subscribe(i => Console.WriteLine(i.Id + "-" + i.IsTest);
Then two events are needed before you can see the output in Subscribe . This is the result of calling First , I'm going. In addition, I also like to use attributes of complex objects in the alarmInterval call.
Can someone give an explanation of what is happening, maybe even a solution? The problem with the transition with an unmodified solution is that the grouping does not look only for identifiers for the key value, as well as the IsTest field.
<edit: As a note, the problem can probably be solved solely by creating an explicit class or structure, and then implement a custom IEquatable , and then using James as- code so that grouping will only occur by identifiers. It looks like a hack, though.