UNPKG

mineflayer-utils

Version:

A collection of small utility classes, functions, and events which work nicely with Mineflayer.

29 lines (28 loc) 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemporarySubscriber = void 0; var Subscription = (function () { function Subscription(eventName, callback) { this.eventName = eventName; this.callback = callback; } return Subscription; }()); var TemporarySubscriber = (function () { function TemporarySubscriber(bot) { this.bot = bot; this.subscriptions = []; } TemporarySubscriber.prototype.subscribeTo = function (event, callback) { this.subscriptions.push(new Subscription(event, callback)); this.bot.on(event, callback); }; TemporarySubscriber.prototype.cleanup = function () { for (var _i = 0, _a = this.subscriptions; _i < _a.length; _i++) { var sub = _a[_i]; this.bot.removeListener(sub.eventName, sub.callback); } }; return TemporarySubscriber; }()); exports.TemporarySubscriber = TemporarySubscriber;