simpleddp-node
Version:
The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments
26 lines (25 loc) • 656 B
JavaScript
;
/**
* DDP change listener class.
* @constructor
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ddpOnChange = ddpOnChange;
function ddpOnChange(obj, inst, listenersArray = 'onChangeFuncs') {
let _isStopped = true;
const start = () => {
if (_isStopped) {
inst[listenersArray].push(obj);
_isStopped = false;
}
};
const stop = () => {
const index = inst[listenersArray].indexOf(obj);
if (index > -1) {
inst[listenersArray].splice(index, 1);
_isStopped = true;
}
};
start();
return { start, stop };
}