2.5.0 • Published 4 months ago
resclient v2.5.0
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.
Installation
With npm:
npm install resclient
With yarn:
yarn add resclient
Example usage
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);
});
Full examples
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.
Usage in Node.js
To connect with WebSockets in Node.js, we must use a library implementing the WebSocket API, such as isomorphic-ws.
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"));
Documentation
2.5.0
4 months ago
2.4.1
10 months ago
2.4.0
2 years ago
2.3.3
2 years ago
2.3.2
2 years ago
2.3.1-alpha.0
3 years ago
2.3.0
3 years ago
2.2.1
3 years ago
2.2.0
4 years ago
2.1.2
4 years ago
2.1.1
4 years ago
2.1.0
4 years ago
2.0.5
5 years ago
2.0.4
5 years ago
2.0.3
5 years ago
2.0.2
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.1.0
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago