Class: Eventsimple::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/eventsimple/dispatcher.rb

Class Method Summary collapse

Class Method Details

.on(*events, sync: [], async: []) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/eventsimple/dispatcher.rb', line 3

def self.on(*events, sync: [], async: [])
  # Register Reactors to Events.
  # * Reactors registered with `sync` will be synced synchronously
  # * Reactors registered with `async` will be synced asynchronously via a Sidekiq Job
  #
  # Example:
  #
  #   on BaseEvent, sync: LogEvent, async: TrackEvent
  #   on PledgeCancelled, PaymentFailed, async: [NotifyAdmin, CreateTask]
  #   on [PledgeCancelled, PaymentFailed], async: [NotifyAdmin, CreateTask]
  #
  EventDispatcher.rules.register(events: events.flatten, sync: Array(sync), async: Array(async))
end