UNPKG

httpgd

Version:

R httpgd GraphicsDevice API and connection handler

33 lines (32 loc) 827 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StateChangeListener = void 0; /** * Simple implementation of a generic state change listener. Keeps track of the * previous state. */ class StateChangeListener { constructor() { this.fun = []; } /** * Notify subscribers of state change. * * @param newState New state. */ notify(newState) { for (let i = 0; i < this.fun.length; ++i) { this.fun[i](newState, this.oldState); } this.oldState = newState; } /** * Listen to state changes. * * @param fun Function to be called on state changes. */ subscribe(fun) { this.fun.push(fun); } } exports.StateChangeListener = StateChangeListener;