Sha256: c88bb888849a1ec2dd230845488574403ea9a890b800f822fbf360e2a59fbb46

Contents?: true

Size: 392 Bytes

Versions: 11

Compression:

Stored size: 392 Bytes

Contents

window.Bait =
  # Wrap our usage of event source:
  # Incoming data is always an Array, the 
  # first value indicates the scope
  # the second value is the callback
  subscribe: (handlers) ->
    source = new EventSource('/events')
    source.addEventListener "message", (e) ->
      data = JSON.parse(e.data)
      handler = handlers[data[0]][data[1]]
      handler.apply(@, data.slice(2))

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bait-0.5.13 app/js/bait.coffee
bait-0.5.12 app/js/bait.coffee
bait-0.5.11 app/js/bait.coffee
bait-0.5.10 app/js/bait.coffee
bait-0.5.9 app/js/bait.coffee
bait-0.5.6 app/js/bait.coffee
bait-0.5.5 app/js/bait.coffee
bait-0.5.4 app/js/bait.coffee
bait-0.5.2 app/js/bait.coffee
bait-0.5.1 app/js/bait.coffee
bait-0.5.0 assets/js/bait.coffee