UNPKG

@virtuous/conductor-events

Version:
98 lines (81 loc) 3.53 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.onUpdate = exports.onDidReset = exports.onWillReset = exports.onDidReplace = exports.onWillReplace = exports.onDidPop = exports.onWillPop = exports.onDidPush = exports.onWillPush = exports.onError = undefined; var _constants = require('@virtuous/conductor/constants'); var events = _interopRequireWildcard(_constants); var _addCallback = require('./addCallback'); var _addCallback2 = _interopRequireDefault(_addCallback); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } /** * Registers a callback to be executed after the error event. * @param {Function} callback The callback to register. */ var onError = exports.onError = function onError(callback) { (0, _addCallback2.default)(events.EVENT_ERROR, callback); }; /** * Registers a callback to be executed before the push event. * @param {Function} callback The callback to register. */ var onWillPush = exports.onWillPush = function onWillPush(callback) { (0, _addCallback2.default)(events.EVENT_WILL_PUSH, callback); }; /** * Registers a callback to be executed after the push event. * @param {Function} callback The callback to register. */ var onDidPush = exports.onDidPush = function onDidPush(callback) { (0, _addCallback2.default)(events.EVENT_DID_PUSH, callback); }; /** * Registers a callback to be executed before the pop event. * @param {Function} callback The callback to register. */ var onWillPop = exports.onWillPop = function onWillPop(callback) { (0, _addCallback2.default)(events.EVENT_WILL_POP, callback); }; /** * Registers a callback to be executed after the pop event. * @param {Function} callback The callback to register. */ var onDidPop = exports.onDidPop = function onDidPop(callback) { (0, _addCallback2.default)(events.EVENT_DID_POP, callback); }; /** * Registers a callback to be executed before the push event. * @param {Function} callback The callback to register. */ var onWillReplace = exports.onWillReplace = function onWillReplace(callback) { (0, _addCallback2.default)(events.EVENT_WILL_REPLACE, callback); }; /** * Registers a callback to be executed after the replace event. * @param {Function} callback The callback to register. */ var onDidReplace = exports.onDidReplace = function onDidReplace(callback) { (0, _addCallback2.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. */ var onWillReset = exports.onWillReset = function onWillReset(callback) { (0, _addCallback2.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. */ var onDidReset = exports.onDidReset = function onDidReset(callback) { (0, _addCallback2.default)(events.EVENT_DID_RESET, callback); }; /** * Registers a callback to be executed after the update event. * @param {Function} callback The callback to register. */ var onUpdate = exports.onUpdate = function onUpdate(callback) { (0, _addCallback2.default)(events.EVENT_UPDATE, callback); };