Search

Nalezeno "Promises": 33

Understanding Async Await


When writing code for the web, eventually you'll need to do some process that might take a few moments to complete. JavaScript can't really multitask, so we'll need a way to handle those long-running processes. Async/Await is a way to handle this type of time-based sequencing. It’s especially great...

JavaScript waitForTime


I write a lot of tests for new features within Firefox DevTools. We have hundreds of “mochitests” which open the browser and perform synthetic actions like clicking, typing, and other user actions. I’ve previously written about waitForever which essentially halts following actions...

Promises and Static Values


Async can throw a real wrench into the cogs of our programming workflows, all despite the fact that async is the modern JavaScript pattern. While async/await helps, there’s sometimes confusion about the way to have a single function that returns a value whether it exists or needs a Promise...

then on Objects


Promises were a revelation in JavaScript development, allowing us to enjoy async processing and avoid callback hell. Many new APIs like Battery API, Cache API, and others use the promise API. One fact you may not know is that you can add a then method to any object to make it Promise-like!...

JavaScript Proxy with Storage


The JavaScript Proxy API provides a wealth of “magic” within JavaScript, allowing you to use any object as sort of an alias that allows a wall of validation, formatting, and error throwing. Did you know that you could also employ the Proxy API as an abstraction to different types...

A Peek at New Methods Coming to Promises


Promises are one of the most celebrated features introduced to JavaScript. Having a native asynchronous artifact baked right into the language has opened up a new era, changing not only how we write code but also setting up the base for other freat APIs — like fetch! Let's step back a moment...

Finally… A Post on Finally in Promises


“When does finally fire in a JavaScript promise?” This is a question I was asked in a recent workshop and I thought I’d write up a little post to clear up any confusion. The answer is, to quote Snape: ...always. The basic structure is like this: try { // I’ll try to execute some code...

JavaScript Detect Async Function


JavaScript async/await has changed the landscape of how we code. We’re no longer stuck in callback or then hell, and our code can feel more “top down” again. Async functions require the following syntax: async function myFunction() { } To use await with a function, the function...

Build a Decentralized Web Chat in 15 Minutes


In this 15 minute tutorial we’re going to build a simple decentralized chat application which runs entirely in a web browser. All you will need is a text editor, a web browser, and a basic knowledge of how to save HTML files and open them in the browser. We’re going...

Write Your First Service Worker in 5 Minutes


What is a service worker? A service worker is a little file that will allow you to cache files and other assets on a user’s machine. How is this different from server-side caching? Because the assets are stored on a user’s machine, rather than a server, there is no need to go across...

Background Sync with Service Workers


Service workers have been having a moment. In March 2018, iOS Safari began including service workers — so all major browsers at this point support offline options. And this is more important than ever — 20% of adults in the United States are without Internet at home, leaving these...

JavaScript waitForever


Writing mochitests for new features in DevTools can be difficult and time-consuming.  There are so many elements interacting in an async manner that I oftentimes find myself using the debugger to debug the debugger!  In the case where it’s unclear what interaction isn’t working...

The Dark Side of Promises


Since the release of es6 many new features have found their way into NodeJS, but non had quite the same impact as promises. Promises have been developed for the browser before es6 was even a thing. There were several implementations that have been used like jQuery’s deferred object before...

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace