README
AuxiliumSocketClient
A lightweight(ish) library for communicating with the socket server.
Installation
npm install --save @auxilium/socket-client
Usage
Bringing it in
import { AuxiliumSocketClient } from '@auxilium/socket-client';
const socket = new AuxiliumSocketClient();
Or, if you're using angular, spin up a new service, and extend it...
import { Injectable } from '@angular/core';
import { AuxiliumSocketClient, /* optional stuffs */ SliceChanges, SliceRecordChanges, SliceCommentChanges} from '@auxilium/socket-client';
@Injectable({
providedIn: 'root'
})
export class SocketService extends AuxiliumSocketClient {
constructor() {
// if you want it pointed at the production/live server:
super();
// if you want it pointed at a local instance of the server
// super(`http://localhost:9300`);
}
}
Notes
socketIdis a readonly property that is set when a connection to the server is established. if you attach this to your api call request objectreq.socket = socket.socketId, it will be theoriginatorin the response calls- where arguments accept spokes, if not provided, they will default to the one set in the
defaultSpoke... so... if you're only doing shit on one spoke, set it..
Key Methods
// call this if your token changes
resume("1uf0dfbhr1g2efdoihqdubovsq", "sandbox")
// listen to records changing...
onRecordChanges(52116, "sandbox")
.subscribe(
(changes: SliceRecordChanges) => {
console.log('heard changes', changes);
})
// listens to comment changes on a slice
onCommentChanges(slice: number, spoke = this.defaultSpokeName)
// listens to changes on the slice itself (note, still janky)
onSliceChanges(slice: number, spoke = this.defaultSpokeName)
Todo
- lots...