JavaScript await was rogue rogue along
a year ago
- #JavaScript
- #Thenables
- #Async
- A Thenable is an object with a .then() method, no Promise required.
- await works with Thenables, making them a flexible alternative to Promises.
- Example shows a Thenable resolving with a value (4 + 2 = 6).
- Custom Thenables can simulate async operations like fetching user profiles.
- Prisma uses Thenables for lazy execution of queries.
- Custom Thenables can be harder to debug than native Promises.
- Promise.resolve() and await use similar mechanisms for Thenables.
- Future language features may standardize patterns currently achieved with Thenables.