npm i --save nativescript-sse
- Version: 4.0.2
- GitHub:
- NPM: https://www.npmjs.com/package/nativescript-sse
- Downloads:
- Last Day: 0
- Last Week: 13
- Last Month: 41
NativeScript Server Sent Events
A NativeScript client for the Server Sent Events (SSE).
Install
npm install nativescript-sse
Usage
import { SSE } from 'nativescript-sse';
let sse = new SSE(serverApi: string, headers: object);
sse.events.on('onConnect', (data) => {
console.log(data.object.connected);
});
sse.events.on('onMessage', (data) => {
this.list.push(JSON.parse(data.object.message.data))
});
sse.events.on('onError', (data) => {
console.log(data.object.error);
});
see.close();