github/ReactiveCocoa — pull request #206 by andrask (2012-12-21 20:11:27+00:00)
Title: bufferWithTime restarts buffering when window closed

The solution schedules the buffering restart on the main queue. This way eliminating some concurrency issue that emerges when the trigger signal is signaled from inside the buffer closing block.

Test:

[[[RACSignal interval:0.1] bufferWithTime:0.5] subscribeNext:^(id x) {
NSLog(@"tick");
}];

Tick should repeat in the console.

Automated testing is really complex as it requires the main queue to be able to run the buffering restart block. This is impossible with the current testing framework. An alternative is to use a queue different from main.

Remark:
The heart of the problem seems to be that the `next` on the start signal is not sensed when run from inside the subscription block where it is now.