Closed BerciTheBeast closed 4 years ago
Thanks for the proposal @BerciTheBeast. I'm afraid this won't work. Getters and setters can not be async
because they are "a replacement" for variable default getter and setter.
var user;
user = 'foo'; // valid
await user = "foo"; // invalid
It's always good practice to have deterministic objects where you also explain what's happening. For example:
model.firstName // a value is present, ok
await model.getRemoveImage() // async process where value is not yet present, ok
What I usually do in your case is this:
const user = new User(); // model instance
await user.loadRemoveImage(); // get remove image and populate the user.image property
user.serialize(); // now I have all the data
I hope this helps.
I propose the addition of having optional async getters.
For example, the following code would be possible and would work:
This would likely also impact serialization.