Registry / messaging / spine-high-templar

spine-high-templar

JSON →
library0.5.0jsnpmunverified

WebSocket addon for MobX-Spine that provides WebSocket creation, keepalive, automatic reconnection, pub/sub via high-templar. Version 0.5.0 (latest, stable). Release cadence is low; maintained by CodeYellowBV. Key differentiators: integrates with MobX-Spine ecosystem, session/token auth via WebSocket upgrade.

npm install spine-high-templar
INSTALL
IMPORT
SIG · SPINE-HIGH-TEMPLAR
S
spine-high-templar
messagingjavascriptv0.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Socket
import { Socket } from 'spine-high-templar'
const Socket = require('spine-high-templar')
ES module; named export.
Socket
import { Socket } from 'spine-high-templar'
import Socket from 'spine-high-templar'
Not a default export; must use named import.
Socket
const { Socket } = require('spine-high-templar')
const Socket = require('spine-high-templar').default
CommonJS usage with destructuring.

Creates a Socket, sets it on the MobX-Spine api, subscribes to a room, and handles cleanup.

import { Socket } from 'spine-high-templar'; import { api } from 'mobx-spine'; const socket = new Socket({ url: process.env.WS_URL ?? 'wss://example.com/socket', token: process.env.AUTH_TOKEN ?? '', }); api.socket = socket; const subscription = socket.subscribe({ room: { tenant: 1, user: '123' }, onPublish: (msg) => console.log('Received:', msg.data), onReconnect: () => console.log('Reconnected'), }); // Later, cleanup componentWillUnmount() { socket.unsubscribe(subscription); }
Debug
Known issues
gotchaSocket must be created after successful bootstrap; headers require authentication.
fix
Only instantiate Socket after bootstrap (e.g., after fetchBootstrap resolves with 200).
affects: >=0.0.0
gotchaToken passed in options is used as Authorization header, but browser WebSocket does not support custom headers; relies on high-templar upgrade request.
fix
Pass token in constructor when using token auth; do not attempt to set custom WebSocket headers.
affects: >=0.0.0
gotchaUnsubscribe in componentWillUnmount to avoid memory leaks; subscriptions persist across reconnects.
fix
Store subscription reference and call socket.unsubscribe(subscription) on unmount.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot read property 'subscribe' of undefined
Socket not instantiated or not assigned to api.socket before subscribing.
fix
Ensure api.socket is set: api.socket = new Socket({...});
WebSocket is closed before the connection is established.
Socket opened before authentication token is available or before bootstrap completes.
fix
Defer socket creation until after successful bootstrap (e.g., after fetchBootstrap resolves).
Upgrade
Version history
0.5.0latest on npm
Audit
Dependencies
mobx-spinerequiredCore dependency for MobX-Spine integration
high-templarrequiredWebSocket and pub/sub logic
Agent activity
19 hits · last 30 days
node
18
OpenAI (training)
1
Resources
spine-high-templar — npm install spine-high-templar · libregistry