Skip to content

Instantly share code, notes, and snippets.

@jeffputz
Last active November 11, 2020 03:59
Show Gist options
  • Save jeffputz/85ce0e74db4d159b60533997ff963e59 to your computer and use it in GitHub Desktop.
Save jeffputz/85ce0e74db4d159b60533997ff963e59 to your computer and use it in GitHub Desktop.
How Blazor interop does work (when you return the promises)
window.IsUrlCached = (url) => {
return caches.open(CACHE_NAME)
.then((cache) => {
return cache.match(url)
.then((response) => {
if (typeof response !== 'undefined')
return true;
else
return false;
});
}
);
}
// from C#:
var isCached = await _jsRuntime.InvokeAsync<bool>("IsUrlCached", url);
// original version failed because I wasn't returning the promises in the chain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment