Skip to content

Commit 71e3a2e

Browse files
Made sure that pause/resume event are called before the actual operations. (and that stack processing is paused if there is a pause command within resume)
1 parent 1161284 commit 71e3a2e

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

PauseWrapper.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,24 +63,22 @@ Object.assign(PauseWrapper.prototype, {
6363
return false
6464
}
6565
this._paused = paused
66-
if (paused) {
67-
this._pauseStack = []
68-
} else {
69-
while (this._pauseStack) {
70-
var pauseStack = this._pauseStack
71-
delete this._pauseStack
72-
while (pauseStack.length > 0) {
73-
var handler = pauseStack.shift()
74-
handler()
75-
}
76-
}
77-
}
7866
this.emit('paused', paused)
7967
if (paused) {
8068
this.emit('pause')
8169
} else {
8270
this.emit('resume')
8371
}
72+
if (paused) {
73+
if (this._pauseStack === undefined) {
74+
this._pauseStack = []
75+
}
76+
} else {
77+
while (this._pauseStack.length > 0 && !this._paused) {
78+
var handler = this._pauseStack.shift()
79+
handler()
80+
}
81+
}
8482
return true
8583
},
8684
pause: function () {

0 commit comments

Comments
 (0)