UNPKG

node-jet

Version:

Jet Realtime Message Bus for the Web. Daemon and Peer implementation.

27 lines (26 loc) 766 B
import { EventEmitter } from '../../1_socket/index.js'; /** * A Route is a path and corresponds to a state. * The daemon keeps a local cache of all registered routes and all momentary values. * The corresponding owner of a route is also remembered */ export class Route extends EventEmitter { owner; value; path; access; constructor(owner, path, value = undefined, access) { super(); this.owner = owner; this.value = value; this.path = path; this.access = access; } updateValue = (newValue) => { if (newValue === this.value) return; this.value = newValue; this.emit('Change', this.path, newValue); }; remove = () => this.emit('Remove', this.path); }