11
22<template >
3- <router-view />
3+ <!-- Get passed down to MyLayout.vue
4+ & listen for custom events emitted from MyLayout.vue -->
5+ <router-view
6+ v-on:undo =" undoTrigger"
7+ v-on:redo =" redoTrigger"
8+ v-bind:done-action =" doneAction"
9+ v-bind:undone-action =" undoneAction"
10+ />
411</template >
512
613<script >
@@ -25,7 +32,8 @@ let redoMixin = {
2532 doneAction: [],
2633 undoneAction: [],
2734 isTimetraveling: false ,
28- initialState: {}
35+ initialState: {},
36+ doneActionLength: 0
2937 }
3038 },
3139 created () {
@@ -35,7 +43,8 @@ let redoMixin = {
3543 // console.log("We saved the world with a deepclone!", action.payload === cloneDeep)
3644 action .payload = cloneDeep (action .payload )
3745 }
38- this .doneAction .push (action)
46+ this .doneAction .push (action);
47+ // console.log(`From app.vue: ${action.payload}`)
3948 // console.log('this is the action we are logging',action)
4049 // console.log('this is in our redo queue', this.undoneAction[this.undoneAction.length-1])
4150 // console.log("Are these equal to each other?", action == this.undoneAction[this.undoneAction.length-1])
@@ -87,7 +96,6 @@ let redoMixin = {
8796 }
8897
8998 this .isTimetraveling = true
90-
9199 let undone = this .doneAction .pop ()
92100
93101 /* assuming we have have something to undo, we check if we are undoing an action that has no feedback
@@ -140,6 +148,18 @@ let redoMixin = {
140148 // console.log('in the redo loop')
141149 this .redo ()
142150 }
151+ },
152+
153+ // Undo triggered from MyLayout.vue
154+ undoTrigger : function () {
155+ const throttledUndo = throttle (this .undo , 300 );
156+ throttledUndo ();
157+ },
158+
159+ // Redo triggered from MyLayout.vue
160+ redoTrigger : function () {
161+ const throttledRedo = throttle (this .redo , 300 );
162+ throttledRedo ();
143163 }
144164 }
145165}
0 commit comments