| @@ -346,15 +346,6 export function debounce<T extends any[] | |||||
| 346 |
|
346 | |||
| 347 | fn.cancel = (e?: any) => cancel(e); |
|
347 | fn.cancel = (e?: any) => cancel(e); | |
| 348 |
|
348 | |||
| 349 | fn.applyAsync = async (thisArg: This, args: T, ct: ICancellation) => { |
|
|||
| 350 | const h = ct.register(cancel); |
|
|||
| 351 | try { |
|
|||
| 352 | await fn.apply(thisArg, args); |
|
|||
| 353 | } finally { |
|
|||
| 354 | h.destroy(); |
|
|||
| 355 | } |
|
|||
| 356 | }; |
|
|||
| 357 |
|
||||
| 358 | return fn; |
|
349 | return fn; | |
| 359 | } |
|
350 | } | |
| 360 |
|
351 | |||
| @@ -138,15 +138,15 test("debounce tests", async (t, trace) | |||||
| 138 | let cancel: (e?: any) => void = notImplemented; |
|
138 | let cancel: (e?: any) => void = notImplemented; | |
| 139 | const ct = new Cancellation(c => cancel = c); |
|
139 | const ct = new Cancellation(c => cancel = c); | |
| 140 |
|
140 | |||
| 141 |
const d = debounce(async ( |
|
141 | const d = debounce(async () => { | |
| 142 |
ct |
|
142 | ct.throwIfRequested(); | |
| 143 | trace.debug("do async increment"); |
|
143 | trace.debug("do async increment"); | |
| 144 | await fork(); |
|
144 | await fork(); | |
| 145 | count++; |
|
145 | count++; | |
| 146 | return count; |
|
146 | return count; | |
| 147 | }, 0); |
|
147 | }, 0); | |
| 148 |
|
148 | |||
| 149 |
const p = d |
|
149 | const p = d().then(undefined, () => rejected++); | |
| 150 | cancel(); |
|
150 | cancel(); | |
| 151 | await p; |
|
151 | await p; | |
| 152 |
|
152 | |||
General Comments 0
You need to be logged in to leave comments.
Login now
