About asynchronous getters/setters again
See original GitHub issueI have read the two discussions (#2571 and #517) that relate to this opportunity, and still do not see any reason to abandon it. Why not? Even if Mongoose should maintain compatibility with the ES5, this does not prevent to check that the setter returns to us. Watch this pseudo-code:
if (setterResult.constructor.name === 'Promise' && setterResult.then) {
promisesArray.push(setterResult.then(
value => {
return {
path: path,
value: value
};
},
err => {
return err;
}
));
}
// ...
if (promisesArray.length){
return Promise.all(promisesArray).then(
results => {
for (let result of results) {
// Do anything with it
}
// Do anything with all fields
return this.save();
},
errors => {
for (let err of errors) {
// Do anything with it
}
return errors;
}
);
} else {
// Do anything with all fields
return this.save();
}
So why not? This is a very useful feature, and it will join naturally in existing.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:12 (1 by maintainers)
Top Results From Across the Web
Async Getters and Setters. Is it Possible? | by David Barral
As you should know by now: Async functions always return a promise. If the return value of an async function is not explicitly...
Read more >How would one do async JavaScript getters and setters?
The get and set function keywords seem to be incompatible with the async keyword. However, since async / await is just a wrapper...
Read more >Async Operations in Property Getters and Setters in WPF
Dear Community: I've been using MVVM for long time (almost 4 years) in WPF and have been using async operations for that long...
Read more >Tableau JavaScript API Concepts--Property Getters and Setters
Getters and setters are always functions that start with get or set . They can be called multiple times with little performance impact...
Read more >How to create and use async properties - Hacking with Swift
Important: This is only possible on read-only computed properties – attempting to provide a setter will cause a compile error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I would be happy to see that feature.
What’s the status?
This would be a great feature to add.