Ring announces security drone flies around inside your home
blog.ring.com4 pointsby wtfrmyinitials0 comments
> import foo from 'foo';
> await foo.bar();
You only have to `await foo.bar()` if foo.bar was an async function already, the module system is irrelevant. You would still need to await it even if it was `require()`'d in. import baz from 'baz';
baz.foo();
Works just fine, no `await` necessary. > await Promise.all([
> import('other'),
> import('stuff'),
> ]);
Of course these have to be awaited, at this point you're explicitly trying to load new code while the program is running. It's no different than any other kind of async IO. > import yet from 'more-stuff';
I assume this is included to imply that loading `yet` is blocked by the `await Promise.all` above it to show that import statements can run after module resolution. If this was your intent you are mistaken, that import statement is still resolved before execution begins. // main.js
console.log('a')
await new Promise(res => setTimeout(res, 1000))
console.log('b')
import { foo } from "./foo.js";
// foo.js
export function foo() {
}
console.log('c')
Results in c
a
[one second pause]
b
> Yes, an import statement is [semantically] blocking. But even so it’s important to know that it’s performing async I/O.