Method: Browser::EventSource#initialize

Defined in:
opal/browser/event_source.rb

#initialize(path) { ... } ⇒ EventSource

Create an Browser::EventSource on the given path.

Parameters:

  • path (String)

    the path to use as source

Yields:

  • if the block has no parameters it's instance_exec'd, otherwise it's called with self


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'opal/browser/event_source.rb', line 25

def initialize(path, &block)
  if native?(path)
    super(path)
  else
    super(`new window.EventSource(path)`)
  end

  if block.arity == 0
    instance_exec(&block)
  else
    block.call(self)
  end if block
end