From 444edc52b6dd5de5418ae8630e1f2270f0114372 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Tue, 13 Dec 2022 12:25:59 +0330 Subject: [PATCH] fix(fetch): always call revalidateCallback --- core/fetch/src/fetch.ts | 2 +- core/fetch/src/type.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/fetch/src/fetch.ts b/core/fetch/src/fetch.ts index f47cabb0d..3962916f6 100644 --- a/core/fetch/src/fetch.ts +++ b/core/fetch/src/fetch.ts @@ -170,7 +170,7 @@ async function _handleCacheStrategy(options: Required): Promise { if (networkResponse.ok) { cacheStorage.put(request, networkResponse.clone()); - if (cachedResponse != null && typeof options.revalidateCallback === 'function') { + if (typeof options.revalidateCallback === 'function') { options.revalidateCallback(networkResponse); } } diff --git a/core/fetch/src/type.ts b/core/fetch/src/type.ts index 32356686e..745d3586a 100644 --- a/core/fetch/src/type.ts +++ b/core/fetch/src/type.ts @@ -68,7 +68,7 @@ export interface FetchOptions extends RequestInit { /** * Revalidate callback for `stale_while_revalidate` cache strategy. */ - revalidateCallback?: (response: Response) => void; + revalidateCallback?: (response: Response) => void | Promise; /** * Cache storage custom name.