1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

More API changes

This commit is contained in:
Pratik Naik 2015-01-17 12:02:05 +05:30
parent 955bf93549
commit 6a78da9249
3 changed files with 10 additions and 7 deletions

View file

@ -27,7 +27,9 @@ module ActionCable
@_active_periodic_timers = [] @_active_periodic_timers = []
@params = params @params = params
setup connect
subscribe
end end
def receive(data) def receive(data)
@ -47,7 +49,7 @@ module ActionCable
end end
protected protected
def setup def connect
# Override in subclasses # Override in subclasses
end end
@ -56,8 +58,10 @@ module ActionCable
end end
def start_periodic_timers def start_periodic_timers
self.class.periodic_timers.each do |method, options| self.class.periodic_timers.each do |callback, options|
@_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) { send(method) } @_active_periodic_timers << EventMachine::PeriodicTimer.new(options[:every]) do
callback.respond_to?(:call) ? callback.call : send(callback)
end
end end
end end

View file

@ -21,8 +21,8 @@ module ActionCable
self.on_unsubscribe_callbacks += methods self.on_unsubscribe_callbacks += methods
end end
def periodic_timer(method, every:) def periodically(callback, every:)
self.periodic_timers += [ [ method, every: every ] ] self.periodic_timers += [ [ callback, every: every ] ]
end end
end end

View file

@ -54,7 +54,6 @@ module ActionCable
if subscription_klass if subscription_klass
@subscriptions[id_key] = subscription_klass.new(self, id_key, id_options) @subscriptions[id_key] = subscription_klass.new(self, id_key, id_options)
@subscriptions[id_key].subscribe
else else
# No channel found # No channel found
end end