lib/volt/reactive/events.rb
def remove_listener(event, listener)
    event = event.to_sym

    raise "Unable to delete #{event} from #{self.inspect}" unless @listeners && @listeners[event]

    @listeners[event].delete(listener)

    last_for_event = @listeners[event].size == 0

    if last_for_event
      # When events are removed, we need to notify any relevent chains so they
      # can remove any chained events.
      event_chain.remove_event(event)

      # No registered listeners now on this event
      @listeners.delete(event)
    end

    last = last_for_event && @listeners.size == 0

    # Let the class we're included on know that we removed a listener (if it cares)
    if self.respond_to?(:event_removed)
      # Pass in the event and a boolean indicating if it is the last event
      self.event_removed(event, last, last_for_event)
    end

    if last
      @has_listeners = nil
    end
  end
# Typically you would call .remove on the listener returned from the .on
# method.  However, here you can also pass in the original proc to remove
# a listener
Typically you would call .remove on the listener returned from the .on
method.  However, here you can also pass in the original proc to remove
a listener
Typically you would call . remove on the listener returned from the . on method . However here you can also pass in the original proc to remove a listener
def remove_listener(event, listener)
    event = event.to_sym
    raise "Unable to delete #{event} from #{self.inspect}" unless @listeners && @listeners[event]
    @listeners[event].delete(listener)
    last_for_event = @listeners[event].size == 0
    if last_for_event
      event_chain.remove_event(event)
      @listeners.delete(event)
    end
    last = last_for_event && @listeners.size == 0
    if self.respond_to?(:event_removed)
      self.event_removed(event, last, last_for_event)
    end
    if last
      @has_listeners = nil
    end
  end
def remove_listener ( event , listener ) event = event . to_sym raise "Unable to delete #{event} from #{self.inspect}" unless @listeners && @listeners [ event ] @listeners [ event ] . delete ( listener ) last_for_event = @listeners [ event ] . size == 0 if last_for_event event_chain . remove_event ( event ) @listeners . delete ( event ) end last = last_for_event && @listeners . size == 0 if self . respond_to? ( :event_removed ) self . event_removed ( event , last , last_for_event ) end if last @has_listeners = nil end end
Typically you would call .remove on the listener returned from the .on
method.
Typically you would call . remove on the listener returned from the . on method .
# When events are removed, we need to notify any relevent chains so they # can remove any chained events. # No registered listeners now on this event # Let the class we're included on know that we removed a listener (if it cares) # Pass in the event and a boolean indicating if it is the last event
event
listener