2.0.0-alpha.9 • Published 6 years ago
crs-client v2.0.0-alpha.9
crs-client
The JavaScript client library for crs
Installaion
npm install crs-client --save
Usage
Typescript / ESNext
import { CrsEndpoint, Command } from 'crs-client';
// Create a command class and bound to a CRS commmand
@Command('supercommand')
class SuperCommand {
constructor(hello) {
this.hello = hello;
}
}
// create a new endpoint where {server url} is your server URL (empty is same origin)
// and {crs endpoint} is the path to the CRS endpoint
const endpoint = new CrsEndpoint('{server url}/{crs endpoint}');
// initialize the endpoint
endpoint.connect();
// send the command
emitter.send(new SuperCommand('hello world!'))
.then(response => {
console.log(response);
});
ES5 in browser
First, include the library crs-client.js
in your HTML
<script src="crs-client.js"></script>
The script will add the Crs
object on the window
object.
// Specify the command name.
Crs.Command('supercommand')(SuperCmd)
function SuperCmd(hello) {
this.hello = hello;
}
// create a new endpoint
var endpoint = new Crs.CrsEndpoint('{server url}/{crs endpoint}');
// initialize the endpoint
endpoint.connect();
// send the command
const response = await endpoint.send(new SuperCmd('hello world!'));
2.0.0-alpha.9
6 years ago
2.0.0-alpha.8
6 years ago
2.0.0-alpha.7
6 years ago
2.0.0-alpha.6
6 years ago
2.0.0-alpha.5
7 years ago
2.0.0-alpha.4
7 years ago
2.0.0-alpha.3
7 years ago
2.0.0-alpha.2
7 years ago
2.0.0-alpha.1
7 years ago
2.0.0-alpha.0
7 years ago
1.0.0-beta.0
7 years ago