UNPKG

camelot-unchained

Version:
50 lines (42 loc) 1.91 kB
/** * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var client_1 = require('../../core/client'); var EVENT_NAME = 'init'; var initialised = false; function run(emitter) { function notify() { emitter.emit(EVENT_NAME, {}); } if (initialised) { notify(); } else { client_1.default.OnInitialized(function () { initialised = true; notify(); }); } } var InitListener = function () { function InitListener() { _classCallCheck(this, InitListener); this.once = true; } _createClass(InitListener, [{ key: 'start', value: function start(emitter) { // for the init listener, we always want to run it // because it may be called post-init, in which case // it needs to fire the handler immediately run(emitter); } }]); return InitListener; }(); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = InitListener;