Description
Currently after
and every
methods are added to the Kernel
module server side, so that Isomorphic Operations can use these methods uniformly on the server and client.
The problem is other gems tend to also add these methods (especially after
) to the kernel.
So rather than add them to the kernel
we should now add them to a module (Hyperstack::AsyncSleep
as both instance and class methods.
Then you can include them in Operation classes (or elsewhere) as needed.
Also making them class level methods on both the server and client, you can say Hyperstack::AsyncSleep.after
or .every
any place without doing the include.
This will be a breaking change, but the work around is to either update the classes that are using after
or every
on the server to include AsyncSleep, or it could be done globally (i.e. include it into Object.)
module Hyperstack
module AsyncSleep
if RUBY_ENGINE == 'opal'
def self.every(*args, &block)
every(*args, &block)
end
def self.after(*args, &block)
after(*args, &block)
end
else
extend self
def every(time, &block)
Thread.new { loop { sleep time; block.call } }
end
def after(time, &block)
Thread.new { sleep time; block.call }
end
end
end
end