Module: ActionCable::Channel::PeriodicTimers::ClassMethods

Defined in:
lib/action_cable/channel/periodic_timers.rb

Instance Method Summary collapse

Instance Method Details

#periodically(callback, every:) ⇒ Object

Allow you to call a private method every so often seconds. This periodic timer can be useful for sending a steady flow of updates to a client based off an object that was configured on subscription. It's an alternative to using streams if the channel is able to do the work internally.


18
19
20
# File 'lib/action_cable/channel/periodic_timers.rb', line 18

def periodically(callback, every:)
  self.periodic_timers += [ [ callback, every: every ] ]
end