UNPKG

typedux

Version:

Slightly adjusted Redux (awesome by default) for TS

94 lines 4.8 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) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "../actions/ActionTypes", "../actions/BaseActionFactory", "../actions/ActionDecorations", "./InternalState", "../constants", "lodash/clone"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InternalActionFactory = void 0; var ActionTypes_1 = require("../actions/ActionTypes"); var BaseActionFactory_1 = require("../actions/BaseActionFactory"); var ActionDecorations_1 = require("../actions/ActionDecorations"); var InternalState_1 = require("./InternalState"); var constants_1 = require("../constants"); var clone_1 = __importDefault(require("lodash/clone")); var InternalActionFactory = /** @class */ (function (_super) { __extends(InternalActionFactory, _super); function InternalActionFactory(store) { return _super.call(this, InternalState_1.InternalState, store) || this; } InternalActionFactory.prototype.leaf = function () { return constants_1.INTERNAL_KEY; }; InternalActionFactory.prototype.setPendingAction = function (action) { return function (state) { var newState = new InternalState_1.InternalState(state), pendingActions = __assign({}, newState.pendingActions), pendingAction = pendingActions[action.id], isFinished = action.status >= ActionTypes_1.ActionStatus.Finished; if (!isFinished && !pendingAction) { newState.totalActionCount++; newState.pendingActionCount++; } else if (isFinished && pendingActions[action.id]) { newState.pendingActionCount--; } newState.hasPendingActions = newState.pendingActionCount > 0; if (!isFinished) { pendingActions[action.id] = clone_1.default(action); } else { delete pendingActions[action.id]; } newState.pendingActions = pendingActions; return newState; }; }; __decorate([ ActionDecorations_1.ActionReducer(), __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], InternalActionFactory.prototype, "setPendingAction", null); return InternalActionFactory; }(BaseActionFactory_1.BaseActionFactory)); exports.InternalActionFactory = InternalActionFactory; }); //# sourceMappingURL=InternalActionFactory.js.map