@asaje/sse-push-event
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

SSE-PUSH-EVENT

Description

Lightweight package for SSE push events handling

Installation

npm i @asaje/sse-push-event

or

yarn add @asaje/sse-push-event

How to use

Client Side

import {
  addPushEventListener,
  initPushEvent,
  joinPushEventRoom,
} from '@asaje/sse-push-event';

initPushEvent('http://localhost:3000/events');

joinPushEventRoom('test-room');

addPushEventListener('TEST', (data) => {
  console.log('Received: ', data);
});

Server Side

// Example of NestJS controller
@Sse('events')
notify(): Observable<any> {
  return initPushEventSubscription();
}


// Sending event
sendPushEvent({
  event: 'TEST',
  data: { msg: 'Hello' },
  room: 'test-room',
})

Readme

Keywords

none

Package Sidebar

Install

npm i @asaje/sse-push-event

Weekly Downloads

8

Version

1.0.9

License

MIT

Unpacked Size

4.12 kB

Total Files

10

Last publish

Collaborators

  • asaje379