UNPKG

react-redux-fetch

Version:

A declarative and customizable way to fetch data for React components and manage that data in the Redux state

73 lines (52 loc) 1.65 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _assign = require('../utils/assign'); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var Definition = function () { function Definition() { var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, Definition); this.args = {}; this.args = args; } /** * Sets a specific argument * @param {String} path The path in args to the value that you want to replace * @param {any} arg The value to set * @return {Definition} The current instance */ Definition.prototype.replaceArgument = function replaceArgument(path, arg) { (0, _assign.assign)(this.args, path, arg); return this; }; /** * Adds an argument * * @param {String} key The key to use * @param {any} arg An argument * @return {Definition} The current instance */ Definition.prototype.addArgument = function addArgument(key, arg) { this.args[key] = arg; return this; }; /** * @return {Object} The object of arguments */ Definition.prototype.getArguments = function getArguments() { return this.args; }; /** * @param {String} key The key of the argument to return * @return {any} The argument */ Definition.prototype.getArgument = function getArgument(key) { if (!this.args[key]) { throw new Error('key ' + key + ' not found in args.'); } return this.args[key]; }; return Definition; }(); exports.default = Definition;