Promises Tutorials
Detect the Content Type in the Clipboard
A user's clipboard is a "catch all" between the operating system and the apps employed on it. When you use a web browser, you can highlight text or right-click an image and select "Copy Image". That made me think about how developers can detect what is...
fetch with Timeout
A few years back I wrote a blog post about how write a
fetch
Promise that times out. The function was effective but the code wasn't great, mostly becauseAbortController
, which allows you to cancel a fetch Promise, did not yet exist. With...How to Determine a JavaScript Promise’s Status
Promises have changed the landscape of JavaScript. Many old APIs have been reincarnated to use Promises (XHR to fetch, Battery API), while new APIs trend toward Promises. Developers can use
async
/await
to handle promises, orthen
/catch
/finally
with callbacks, but what Promises don't tell...Detecting Fonts Ready
Knowing when resources are loaded is a key part of building functional, elegant websites. We're used to using the
DOMContentLoaded
event (commonly referred to as "domready") but did you know there's an event that tells you when all fonts have loaded? Let's learn how...How to Use Storage in Web Extensions
Working on a web extension is an interesting experience -- you get to taste web while working with special extension APIs. One such API is
storage
-- the web extension flavor of persistence. Let's explore how you can usesession
andlocal
storage within...navigator.clipboard API
Reading from and writing to the user's clipboard can be both a very useful and dangerous capability. Used correctly and it's a huge convenience to the user; used dubiously and the user could suffer catastrophic consequences. Imagine a wrong account number or wallet address...
JavaScript Wake Lock API
An enjoyable web apps rely on engineers implementing the APIs that cover all of the small things. Those small things sometimes improve performance, usability, accessibility, and the app's relationship with its host system. The Wake Lock API is the latter -- an API...
navigator.clipboard API
Interacting with a user's host clipboard is something web developers have wanted for both good and evil purposes. On the good side, it's nice to allow users to easily copy text like wallet addresses or branch names; for evil, copying malicious text that the user...
Return a Default Value with Promises Using catch
Last week I tweeted all of you looking for your best JavaScript Array and Promise tricks, and as always, it didn't disappoint -- I learned quite a bit!Today's JavaScript Promise trick is brought to you by Claudio Semeraro: how to use
catch
to...Limit Promise Concurrency with pool
Methods like
Promise.all
,Promise.allSettled
,Promise.race
, and the rest are really excellent for managing multiple Promises, allowing for our apps to embrace async and performance. There are times, however, that limiting the number of concurrent operations may be useful, like rate limiting or simply not wanting...