Sha256: f4ca7561119afa575550e3b21fd4521e2b3bbe52f01093e16f67e9fadfd91dbd
Contents?: true
Size: 915 Bytes
Versions: 2
Compression:
Stored size: 915 Bytes
Contents
module Faye::WebSocket::API module EventTarget attr_accessor :onopen, :onmessage, :onerror, :onclose def add_event_listener(event_type, listener, use_capture = false) @listeners ||= {} list = @listeners[event_type] ||= [] list << listener end def remove_event_listener(event_type, listener, use_capture = false) return unless @listeners and @listeners[event_type] return @listeners.delete(event_type) unless listener @listeners[event_type].delete_if(&listener.method(:==)) end def dispatch_event(event) event.target = event.current_target = self event.event_phase = Event::AT_TARGET callback = __send__("on#{ event.type }") callback.call(event) if callback return unless @listeners and @listeners[event.type] @listeners[event.type].each do |listener| listener.call(event) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
faye-websocket-0.4.7-java | lib/faye/websocket/api/event_target.rb |
faye-websocket-0.4.7 | lib/faye/websocket/api/event_target.rb |