rubymotion/BubbleWrap — pull request #190 by notproperlycut (2013-02-03 22:09:37+00:00)
Title: Allow periodic timers to be scheduled in the "common modes" of a runloop

A UIScrollView was preventing my BubbleWrap::Reactor::PeriodicTimer from firing. http://stackoverflow.com/a/2742275 points at the solution - the timer can be scheduled to fire in the common modes of the runloop, rather than the default.

I tried to enable this in an additive way - without changing the default scheduling of BubbleWrap timers and also leaving the existing implementation of EventMachine APIs intact. Ruby is apparently happy to insert an options hash at the end of a (splat) args array when required, so I can use *args to collect both an optional proc/lambda for the callback and any options.

So
def add_periodic_timer(interval, callback=nil, &blk)
became
def add_periodic_timer(interval, *args, &blk)

Simply adding an options = {} argument
def add_periodic_timer(interval, callback=nil, options = {}, &blk)
did not result in the correct behaviour when :common_modes => true is supplied, but the callback is not.