UNPKG

meteor-sdk

Version:

The aim of this library is to simplify the process of working with meteor server over DDP protocol using external JS environments

22 lines (21 loc) 586 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ddpEventListener = void 0; function ddpEventListener(eventname, f, ddplink) { let _started = false; const start = () => { if (!_started) { ddplink.ddpConnection.on(eventname, f); _started = true; } }; const stop = () => { if (_started) { ddplink.ddpConnection.removeListener(eventname, f); _started = false; } }; start(); return { start, stop }; } exports.ddpEventListener = ddpEventListener;