UNPKG

@aitianyu.cn/tianyu-store

Version:
49 lines 2.41 kB
"use strict"; /** @format */ Object.defineProperty(exports, "__esModule", { value: true }); exports.ActionProcessorMap = void 0; const Action_1 = require("../../types/Action"); const InstanceIdImpl_1 = require("../impl/InstanceIdImpl"); function creatorProcessor(executor, manager, action, newState, notRedoUndo) { // for create action, to make difference between entity creation and instance creation if (InstanceIdImpl_1.InstanceIdImpl.isAncestor(action.instanceId)) { // when the instance id equals to ancestor // that means the instance is for entity id itself // the new state is IStoreState type const newStoreState = newState; manager.createEntity(action.instanceId, newStoreState); } else { // to create internal object executor.pushStateChange(action.storeType, action.instanceId.toString(), action.actionType, newState || {}, notRedoUndo); } } function destroyProcessor(executor, manager, action, _newState, notRedoUndo) { // for destroy action, to make difference between entity creation and instance creation if (InstanceIdImpl_1.InstanceIdImpl.isAncestor(action.instanceId)) { // when the instance id equals to ancestor // that means the instance is for entity id itself // the operation should be a management operation manager.destroyEntity(action.instanceId); } else { // to make internal object to be undefined executor.pushStateChange(action.storeType, action.instanceId.toString(), action.actionType, undefined, notRedoUndo); } } function redoUndoProcessor(executor, _manager, _action, newState, _notRedoUndo) { executor.pushDiffChange(newState); } function actionProcessor(executor, _manager, action, newState, notRedoUndo) { // for other actions, to set the states directly executor.pushStateChange(action.storeType, action.instanceId.toString(), action.actionType, newState, notRedoUndo); } exports.ActionProcessorMap = { [Action_1.ActionType.ACTION]: actionProcessor, [Action_1.ActionType.VIEW_ACTION]: actionProcessor, [Action_1.ActionType.CREATE]: creatorProcessor, [Action_1.ActionType.DESTROY]: destroyProcessor, [Action_1.ActionType.UNDO]: redoUndoProcessor, [Action_1.ActionType.REDO]: redoUndoProcessor, }; //# sourceMappingURL=ActionProcessor.js.map