UNPKG

derby

Version:

MVC framework making it easy to write realtime, collaborative applications that run in both Node.js and browsers.

66 lines (65 loc) 2.33 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Controller = void 0; var events_1 = require("events"); var Dom_1 = require("./Dom"); var Controller = /** @class */ (function (_super) { __extends(Controller, _super); function Controller(app, page, model) { var _this = _super.call(this) || this; _this.dom = new Dom_1.Dom(_this); _this.app = app; _this.model = model; _this.page = page; model.data.$controller = _this; return _this; } Controller.prototype.emitCancellable = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var cancelled = false; function cancel() { cancelled = true; } args.push(cancel); // eslint-disable-next-line prefer-spread this.emit.apply(this, args); return cancelled; }; Controller.prototype.emitDelayable = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var callback = args.pop(); var delayed = false; function delay() { delayed = true; return callback; } args.push(delay); // eslint-disable-next-line prefer-spread this.emit.apply(this, args); if (!delayed) callback(); return delayed; }; return Controller; }(events_1.EventEmitter)); exports.Controller = Controller;