UNPKG

@virtuous/conductor

Version:
120 lines (88 loc) 4.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "addCallback", { enumerable: true, get: function get() { return _addCallback["default"]; } }); exports.onUpdate = exports.onDidReset = exports.onWillReset = exports.onDidReplace = exports.onWillReplace = exports.onDidPop = exports.onWillPop = exports.onDidPush = exports.onWillPush = void 0; var events = _interopRequireWildcard(require("../constants")); var _addCallback = _interopRequireDefault(require("./addCallback")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /** * Registers a callback to be executed before the push event. * @param {Function} callback The callback to register. */ var onWillPush = function onWillPush(callback) { (0, _addCallback["default"])(events.EVENT_WILL_PUSH, callback); }; /** * Registers a callback to be executed after the push event. * @param {Function} callback The callback to register. */ exports.onWillPush = onWillPush; var onDidPush = function onDidPush(callback) { (0, _addCallback["default"])(events.EVENT_DID_PUSH, callback); }; /** * Registers a callback to be executed before the pop event. * @param {Function} callback The callback to register. */ exports.onDidPush = onDidPush; var onWillPop = function onWillPop(callback) { (0, _addCallback["default"])(events.EVENT_WILL_POP, callback); }; /** * Registers a callback to be executed after the pop event. * @param {Function} callback The callback to register. */ exports.onWillPop = onWillPop; var onDidPop = function onDidPop(callback) { (0, _addCallback["default"])(events.EVENT_DID_POP, callback); }; /** * Registers a callback to be executed before the push event. * @param {Function} callback The callback to register. */ exports.onDidPop = onDidPop; var onWillReplace = function onWillReplace(callback) { (0, _addCallback["default"])(events.EVENT_WILL_REPLACE, callback); }; /** * Registers a callback to be executed after the replace event. * @param {Function} callback The callback to register. */ exports.onWillReplace = onWillReplace; var onDidReplace = function onDidReplace(callback) { (0, _addCallback["default"])(events.EVENT_DID_REPLACE, callback); }; /** * Registers a callback to be executed before the history has been reset. * @param {Function} callback The callback to register. */ exports.onDidReplace = onDidReplace; var onWillReset = function onWillReset(callback) { (0, _addCallback["default"])(events.EVENT_WILL_RESET, callback); }; /** * Registers a callback to be executed after the history has been reset. * @param {Function} callback The callback to register. */ exports.onWillReset = onWillReset; var onDidReset = function onDidReset(callback) { (0, _addCallback["default"])(events.EVENT_DID_RESET, callback); }; /** * Registers a callback to be executed after the update event. * @param {Function} callback The callback to register. */ exports.onDidReset = onDidReset; var onUpdate = function onUpdate(callback) { (0, _addCallback["default"])(events.EVENT_UPDATE, callback); }; exports.onUpdate = onUpdate;