4 ms·
Maybe I'm crazy but I'd much prefer that as: const temp = await foo; const bar = await temp.bar; const baz = await bar.baz; But then again it looks l
by reggieband 8y ago
Maybe I'm crazy but I'd much prefer that as:
const temp = await foo;
const bar = await temp.bar;
const baz = await bar.baz;
But then again it looks like in this example we are returning promises from getters on objects which is something I would avoid.
- munificent 8y agoYeah, the guidance is usually to hoist the subexpressions out to variables like you do here. But I encounter it often enough that it feels like we are trying to paper over a poor language syntax. > we are returning promises from getters on objects which is something I would avoid. Getters are very common in Dart and it's idiomatic to use them even for properties that are asynchronous. (It's not like making it a method with an extra `()` really solves anything.) It's not as common to have nested chains of asynchronous properties, but they do happen, especially in tests.