Class: Volt::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.
3 4 5 6 7 |
# File 'lib/volt/reactive/eventable.rb', line 3 def initialize(klass, event, callback) @klass = klass @event = event @callback = callback end |
Instance Method Details
#call(*args) ⇒ Object
9 10 11 |
# File 'lib/volt/reactive/eventable.rb', line 9 def call(*args) @callback.call(*args) unless @removed end |
#inspect ⇒ Object
23 24 25 |
# File 'lib/volt/reactive/eventable.rb', line 23 def inspect "<Listener:#{object_id} event=#{@event}>" end |
#remove ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/volt/reactive/eventable.rb', line 13 def remove @removed = true @klass.remove_listener(@event, self) # Make things easier on the GC @klass = nil @callback = nil end |