UNPKG

react-router-navigation-confirm

Version:

A collection of components to display a custom confirmation dialog on navigation. More flexible solution to prevent than default react-router 'Prompt'

29 lines 982 B
var HistoryService = /** @class */ (function () { function HistoryService() { var _this = this; this.history = []; this.getHistoryFunction = function (location, action) { return { POP: function () { return (_this.isForward(location.key) ? "goForward" : "goBack"); }, PUSH: function () { return "push"; }, REPLACE: function () { return "replace"; } }[action](); }; } HistoryService.prototype.add = function (key) { if (!key) { return; } if (this.history.indexOf(key) < 0) { this.history.push(key); } this.prev = key; }; HistoryService.prototype.isForward = function (current) { return (!!current && this.history.indexOf(current) > this.history.indexOf(this.prev)); }; return HistoryService; }()); export { HistoryService }; //# sourceMappingURL=history-service.js.map