Module: Nimo::EventListener
- Included in:
- ObjectRepresentation, Screen
- Defined in:
- lib/nimo/listeners/event_listener.rb
Overview
Listen for events and execute for actions on notification.
Instance Method Summary collapse
-
#listen_to(event, &action) ⇒ Object
Register an action to be executed when an event is notified.
-
#notify(event) ⇒ Object
Execute registered action for notified event.
Instance Method Details
#listen_to(event, &action) ⇒ Object
Register an action to be executed when an event is notified.
9 10 11 |
# File 'lib/nimo/listeners/event_listener.rb', line 9 def listen_to(event, &action) events[event] = action end |
#notify(event) ⇒ Object
Execute registered action for notified event.
15 16 17 |
# File 'lib/nimo/listeners/event_listener.rb', line 15 def notify(event) events[event].call if events.has_key?(event) end |