1 | "use strict";
|
2 | var DagGraph_1 = require("../DagGraph");
|
3 | var log = require('debug')('redux-dag-history:DagHistory');
|
4 | function replaceCurrentState(state, history, config) {
|
5 | log('replace current state');
|
6 | var graph = history.graph;
|
7 | var reader = new DagGraph_1.default(graph);
|
8 | var currentStateId = reader.currentStateId;
|
9 | return {
|
10 | current: state,
|
11 | graph: graph.withMutations(function (g) {
|
12 | var graph = new DagGraph_1.default(g);
|
13 | if (config.stateKeyGenerator) {
|
14 | var hash = config.stateKeyGenerator(state);
|
15 | log('inserting state with key', hash);
|
16 | graph.setHashForState(hash, currentStateId);
|
17 | }
|
18 | return graph.replaceState(currentStateId, state);
|
19 | }),
|
20 | };
|
21 | }
|
22 | Object.defineProperty(exports, "__esModule", { value: true });
|
23 | exports.default = replaceCurrentState;
|