This document has moved to: https://anthonysteele.github.io/AsyncBasicMistakes
I see a lot of code lately that makes some simple mistakes using the async ... await
construct.
- A Task is a promise of a value.
I see a lot of code lately that makes some simple mistakes using the async ... await
construct.
[based on a true story]
So. Your friend's about to teach you how to make a website. Great!
You make a file, and you save it as 'index.html'. Why it's called 'index' isn't really explained to you, but whatever.
You type the following.
hello world
Sometimes you just need to quickly take some notes.
A trick is to use the data:
scheme with data:text/html
to show just a piece of HTML in your browser.
Then using the mighty contentEditable
to make the whole thing editable.
To copy/paste into your browser address bar:
data:text/html,<html contenteditable>
I recently had several days of extremely frustrating experiences with service workers. Here are a few things I've since learned which would have made my life much easier but which isn't particularly obvious from most of the blog posts and videos I've seen.
I'll add to this list over time – suggested additions welcome in the comments or via twitter.com/rich_harris.
Chrome 51 has some pretty wild behaviour related to console.log
in service workers. Canary doesn't, and it has a load of really good service worker related stuff in devtools.
{ | |
if (window.runTTS === undefined) { | |
const MAX_TRIES = 20; | |
const TRY_DELAY = 100; | |
/* Adjust voice speed. Default = 1 */ | |
if (navigator.userAgent.includes("Macintosh")) { | |
window.ttsPlaybackSpeed = 1.2; | |
} else if (navigator.userAgent.includes("Windows")) { | |
window.ttsPlaybackSpeed = 5; | |
} else { |
With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.
This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async
+ await
.
import React from "react"; | |
import { render } from "react-dom"; | |
const ParentComponent = React.createClass({ | |
getDefaultProps: function() { | |
console.log("ParentComponent - getDefaultProps"); | |
}, | |
getInitialState: function() { | |
console.log("ParentComponent - getInitialState"); | |
return { text: "" }; |