Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@rexxars/eventsource-polyfill

rexxars86.9kMIT1.0.0

A browser polyfill for W3C EventSource (http://www.w3.org/TR/eventsource/)

sse, server, sent, events, eventsource, event-source, polyfill

readme

EventSource Polyfill

Forked from amvtek/EventSource. See fork modification for more details.

Provide polyfill to support EventSource in browser where it is not available.

  • Used in production
  • Tested in Internet Explorer 8 +
  • Tested in Android browser 2.1 +
  • [Documented][]
  • Run the [Browser test suite][]

Installing

$ npm install @rexxars/eventsource-polyfill

Usage (through bundler)

const EventSource =
  typeof window !== 'undefined' && window.EventSource
    ? window.EventSource
    : require('@rexxars/eventsource-polyfill')

const es = new EventSource('/my-es-endpoint')

Usage (drop-in script)

<script src="https://unpkg.com/@rexxars/eventsource-polyfill"></script>
<script>
  var es = new EventSource('/my-es-endpoint')
</script>

Fork modifications

  • New package name: @rexxars/eventsource-polyfill
  • UMD module definition - CommonJS, AMD and browser globals
  • Fixed a few global variable leaks-
  • Check for window.location before usage (fixes react native crashing)
  • Stop dispatching events after closed

License

MIT-licensed. See LICENSE.