(onComplete?: () => void, enabled?: boolean)
| 174 | } |
| 175 | |
| 176 | execute(onComplete?: () => void, enabled?: boolean) { |
| 177 | // eslint-disable-next-line @typescript-eslint/no-this-alias |
| 178 | const self = this; |
| 179 | |
| 180 | this.onStart(this); |
| 181 | |
| 182 | if ( |
| 183 | !this.isExecutable() || |
| 184 | this.markedPending || |
| 185 | this.markedTodo || |
| 186 | enabled === false |
| 187 | ) { |
| 188 | complete(enabled); |
| 189 | return; |
| 190 | } |
| 191 | |
| 192 | const fns = this.beforeAndAfterFns(); |
| 193 | const allFns = fns.befores.concat(this.queueableFn).concat(fns.afters); |
| 194 | |
| 195 | this.currentRun = this.queueRunnerFactory({ |
| 196 | queueableFns: allFns, |
| 197 | onException() { |
| 198 | // @ts-expect-error: wrong context |
| 199 | self.onException.apply(self, arguments); |
| 200 | }, |
| 201 | userContext: this.userContext(), |
| 202 | setTimeout, |
| 203 | clearTimeout, |
| 204 | fail: () => {}, |
| 205 | }); |
| 206 | |
| 207 | this.currentRun.then(() => complete(true)); |
| 208 | |
| 209 | function complete(enabledAgain?: boolean) { |
| 210 | self.result.status = self.status(enabledAgain); |
| 211 | self.resultCallback(self.result); |
| 212 | |
| 213 | if (onComplete) { |
| 214 | onComplete(); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | cancel() { |
| 220 | if (this.currentRun) { |
no test coverage detected