Module: Emittance::Watcher

Defined in:
lib/emittance/watcher.rb

Overview

Can watch for events that propagate through the system.

Instance Method Summary collapse

Instance Method Details

#watch(identifier, callback_method = nil, **params, &callback) ⇒ Proc

Watch for an event, identified by its class' identifier. If a callback method is provided, then it will call that method on the caller of watch when the event happens. Otherwise, it will run the callback block.


18
19
20
21
22
23
24
# File 'lib/emittance/watcher.rb', line 18

def watch(identifier, callback_method = nil, **params, &callback)
  if callback
    _dispatcher(params).register identifier, params, &callback
  else
    _dispatcher(params).register_method_call identifier, self, callback_method, params
  end
end