From c4a92b0b601bf880afc7315db986e9209ff01f5c Mon Sep 17 00:00:00 2001 From: Dave Hadka Date: Mon, 13 Jul 2020 16:07:58 -0500 Subject: [PATCH] Update with reviewer feedback --- packages/cache/src/internal/downloadUtils.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/cache/src/internal/downloadUtils.ts b/packages/cache/src/internal/downloadUtils.ts index 6286322f..69f162e9 100644 --- a/packages/cache/src/internal/downloadUtils.ts +++ b/packages/cache/src/internal/downloadUtils.ts @@ -120,12 +120,12 @@ export class DownloadProgress { } /** - * Callback used to update the progress. - * - * @param progress the progress event + * Returns a function used to handle TransferProgressEvents. */ - onProgressCallback(progress: TransferProgressEvent): void { - this.setReceivedBytes(progress.loadedBytes) + onProgress(): (progress: TransferProgressEvent) => void { + return (progress: TransferProgressEvent) => { + this.setReceivedBytes(progress.loadedBytes) + } } /** @@ -261,9 +261,7 @@ export async function downloadCacheStorageSDK( segmentSize, { concurrency: options.downloadConcurrency, - onProgress: downloadProgress.onProgressCallback.bind( - downloadProgress - ) + onProgress: downloadProgress.onProgress() } )