@tonconnect/isomorphic-eventsource
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@tonconnect/isomorphic-eventsource

This package provides EventSource applicable in different environments (browser & NodeJS).

Get started

npm i @tonconnect/isomorphic-eventsource

How to use

Just import the package and use global EventSource constructor:

import '@tonconnect/isomorphic-eventsource';

const eventSourceInstance = new EventSource();

That will work in both browser and NodeJS.

How does it work

This package exports an empty script if bundler creates browser-compatible build. When package is imported in NodeJS environment, it assigns an EventSource imported from the eventsource package to the global variable.

Note that this package doesn't provide an EventSource polyfill for browsers which doesn't support EventSource natively.

Package Sidebar

Install

npm i @tonconnect/isomorphic-eventsource

Weekly Downloads

9,237

Version

0.0.2

License

Apache-2.0

Unpacked Size

13.6 kB

Total Files

7

Last publish

Collaborators

  • thekiba
  • oleganza
  • siandreev
  • tonconnectadmin