An universal JavaScript client of TreeNews WebSocket
Written in TypeScript with definitions typings
$ npm install --save @iam4x/treenews
If you are working in a node.js/server environment, you need to install ws package as well:
$ npm install --save ws
Simple example:
import { TreeNews } from '@iam4x/treenews';
const treeNews = new TreeNews({
onNews: (news) => console.log(JSON.stringify(news, null, 4));
});
// connect to websocket
treeNews.start();
// close connection to websocket
treeNews.stop();
{
autoReconnect?: boolean; // default: true
autoReconnectTimeout?: number; // default: to 1 second (in seconds)
autoStart?: boolean;
apiKey?: string;
debug?: boolean;
onOpen?: (event: Event) => void;
onError?: (event: Event) => void;
onNews?: (news: News) => void;
onMessage?: (event: MessageEvent) => void;
onClose?: (event: CloseEvent) => void;
}
If you found this project interesting or useful, create accounts with my referral links:
Or buy me a coffee with a crypto donation:
- ETH/BSC/MATIC:
0xFF2da578C73bC694fd767A1CC77160002C2003E6
- Initial release
Feel free to create issues, PRs and start a discussion ❤️