API and connection handler to connect with R httpgd servers.
- Simplify
httpgd
server access from JavaScript - Full TypeScript type definitions
- Automatic WebSocket connection with polling fallback and reconnection
Minimal example how to listen for server side changes:
import { Httpgd } from 'httpgd';
const httpgd = new Httpgd('127.0.0.1:1234', 'mytoken', true);
httpgd.onPlotsChanged((newState) => console.log(newState));
httpgd.connect();
// httpgd.removePlot(...)
// httpgd.getPlotURL(...)
Advanced usage example: The client included in the httpgd R package.
In applications where there is no need to continuously listen for server side changes, httpgd
APIs can also be called directly using the api
module.
Example:
import { url_plot } from 'httpgd/lib/api';
const url = url_plot({ host: '127.0.0.1:1234' }, { id: 'myPlotId' });
document.getElementsByTagName('img')[0].src = url;
MIT