DEV Community

Discussion on: The Proper Way to Write Async Constructors in JavaScript

tehmoros profile image
Piotr "MoroS" Mrożek

Indeed, the async factory functions (methods if anyone prefers) seem to be the cleanest solution to the problem. Everything remains bound to the class itself. Initializing itself is still the responsibility of the class, not some outside function, we don't break the default constructor contract and avoid a ton of internal state control code inside the class. Nice. 🙂