UNPKG

@robotlegsjs/core

Version:

An architecture-based IoC framework for JavaScript/TypeScript

92 lines 3.08 kB
"use strict"; // ------------------------------------------------------------------------------ // Copyright (c) 2017-present, RobotlegsJS. All Rights Reserved. // // NOTICE: You are permitted to use, modify, and distribute this file // in accordance with the terms of the license agreement accompanying it. // ------------------------------------------------------------------------------ Object.defineProperty(exports, "__esModule", { value: true }); exports.CommandMapper = void 0; var CommandMapping_1 = require("./CommandMapping"); /** * @private */ var CommandMapper = /** @class */ (function () { /*============================================================================*/ /* Constructor */ /*============================================================================*/ /** * Creates a Command Mapper * * @param mappings The command mapping list to add mappings to */ function CommandMapper(mappings) { this._mappings = mappings; } /*============================================================================*/ /* Public Functions */ /*============================================================================*/ /** * @inheritDoc */ CommandMapper.prototype.toCommand = function (commandClass) { this._mapping = new CommandMapping_1.CommandMapping(commandClass); this._mappings.addMapping(this._mapping); return this; }; /** * @inheritDoc */ CommandMapper.prototype.fromCommand = function (commandClass) { this._mappings.removeMappingFor(commandClass); }; /** * @inheritDoc */ CommandMapper.prototype.fromAll = function () { this._mappings.removeAllMappings(); }; /** * @inheritDoc */ CommandMapper.prototype.once = function (value) { if (value === void 0) { value = true; } this._mapping.setFireOnce(value); return this; }; /** * @inheritDoc */ CommandMapper.prototype.withGuards = function () { var _a; var guards = []; for (var _i = 0; _i < arguments.length; _i++) { guards[_i] = arguments[_i]; } (_a = this._mapping).addGuards.apply(_a, guards); return this; }; /** * @inheritDoc */ CommandMapper.prototype.withHooks = function () { var _a; var hooks = []; for (var _i = 0; _i < arguments.length; _i++) { hooks[_i] = arguments[_i]; } (_a = this._mapping).addHooks.apply(_a, hooks); return this; }; /** * @inheritDoc */ CommandMapper.prototype.withPayloadInjection = function (value) { if (value === void 0) { value = true; } this._mapping.setPayloadInjectionEnabled(value); return this; }; return CommandMapper; }()); exports.CommandMapper = CommandMapper; //# sourceMappingURL=CommandMapper.js.map