Re:Go 2 Draft Designs
by reggieband on Tuesday August 28, 2018 @06:38PM
(#17863566)
Maybe I'm crazy but I'd much prefer that as:
But then again it looks like in this example we are returning promises from getters on objects which is something I would avoid.
[ Parent
| on HN ]
Re:Go 2 Draft Designs
by munificent on Tuesday August 28, 2018 @07:14PM
(#17863756)
Yeah, 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.