Class: Listener
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(klass, event, callback) ⇒ Listener
constructor
A new instance of Listener.
- #inspect ⇒ Object
- #remove ⇒ Object
Constructor Details
#initialize(klass, event, callback) ⇒ Listener
Returns a new instance of Listener.
2 3 4 5 6 |
# File 'lib/volt/reactive/eventable.rb', line 2 def initialize(klass, event, callback) @klass = klass @event = event @callback = callback end |
Instance Method Details
#call(*args) ⇒ Object
8 9 10 |
# File 'lib/volt/reactive/eventable.rb', line 8 def call(*args) @callback.call(*args) unless @removed end |
#inspect ⇒ Object
22 23 24 |
# File 'lib/volt/reactive/eventable.rb', line 22 def inspect "<Listener:#{object_id} event=#{@event}>" end |
#remove ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/volt/reactive/eventable.rb', line 12 def remove @removed = true @klass.remove_listener(@event, self) # Make things easier on the GC @klass = nil @callback = nil end |