- applyLogEntry: function (entry: string) {
- const [timestamp, command, data] = splitN(entry, " ", 2);
- if (command == "Create") {
- Model.addTask(data);
- }
- },
-};
+ applyLogEntry: function (entry: string) {
+ const [timestamp, command, data] = splitN(entry, " ", 2);
+ if (command == "Create") {
+ Model.addTask(data);
+ }
+ },
+
+ recordLogEntry: function (entry: string) {
+ window.localStorage.setItem(`${next_log_index++}`, entry);
+ },
+
+ recordAndApplyLogEntry: function (entry: string) {
+ this.recordLogEntry(entry);
+ this.applyLogEntry(entry);
+ },
+
+ replay: function () {
+ while (true) {
+ const entry = window.localStorage.getItem(`${next_log_index}`);
+ if (entry === null) {
+ break;
+ }
+ this.applyLogEntry(entry);
+ next_log_index++;
+ }
+ },
+ };
+})();