-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.ts
37 lines (26 loc) · 819 Bytes
/
App.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Editor } from "./Editor"
import { History } from "./History"
import { Snapshot } from "./Mementos"
export default class MementoExample {
editor: Editor
history: History
constructor(){
this.editor = new Editor()
this.history = new History()
this.run()
}
run(): void {
this.editor.text = "Version 1.0"
this.history.add(new Snapshot(this.editor))
this.editor.text = "Version 1.1"
this.history.add(new Snapshot(this.editor))
this.editor.text = "Version 1.2"
this.history.add(new Snapshot(this.editor))
this.history.undo()
console.log(this.editor.text)
this.history.undo()
console.log(this.editor.text)
this.history.undo()
console.log(this.editor.text)
}
}