Resgate client implementing the RES-Client Protocol.
npm install @spindle/resclient---
Javascript client library implementing the RES-Client Protocol. Used to establish WebSocket connections to Resgate, to get your data synchronized in real-time.
Visit Resgate.io for more information.
With npm:
``sh`
npm install resclient
With yarn:
`sh`
yarn add resclient
Create a new version with npm.
`sh`
npm version
Push the new commit and tag.
`sh`
git push --follow-tags
`javascript
import ResClient from 'resclient';
const client = new ResClient('ws://localhost:8080/ws');
client.get('example.mymodel').then(model => {
console.log(model.message);
let onChange = () => {
console.log("New message: " + model.message);
};
// Listen to changes for 5 seconds, eventually unsubscribing
model.on('change', onChange);
setTimeout(() => {
model.off('change', onChange);
}, 5000);
});
`
| Example | Description
| --- | ---
| React | React client implementation of the Book Collection example.
| Vue.js | Vue.js client implementation of the Book Collection example.
| Vue 3 | Vue 3 client implementation of the Book Collection example.
| Modapp | Book Collection example from Resgate repository
> Note
>
> All examples are complete with both service and client.
To connect with WebSockets in Node.js, we must use a library implementing the WebSocket API, such as isomorphic-ws.
`javascript``
var WebSocket = require('isomorphic-ws');
var ResClient = require('resclient').default;
// Create instance with a WebSocket factory function
var client = new ResClient(() => new WebSocket("ws://localhost:8080"));