-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix remove & other promise returning functions #833
Conversation
This change increased the minfied size by 1kB. /**
* @return {Promise}
*/
_proto2.countAllUndeleted =
/*#__PURE__*/
function () {
var _countAllUndeleted = _asyncToGenerator(
/*#__PURE__*/
_regeneratorRuntime.mark(function _callee3() {
return _regeneratorRuntime.wrap(function _callee3$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
return _context4.abrupt("return", PouchDB.countAllUndeleted(this.pouchdb));
case 1:
case "end":
return _context4.stop();
}
}
}, _callee3, this);
}));
return function countAllUndeleted() {
return _countAllUndeleted.apply(this, arguments);
};
}(); And before it was: _proto2.countAllUndeleted = function countAllUndeleted() {
return PouchDB.countAllUndeleted(this.pouchdb);
}; |
Sorry for the delay @pubkey , I've been pretty caught up this past week. I would personally make that trade-off, as I'd have the ensurance that async returning functions will not throw and interrupt execution without having to think about anything else than declaring them as async, and hopefully we'll be at the point of not needing transpilation for async/await soon enough. But I can definitely see your point. An alternative would be to either only do this for public functions and methods, or do try/catch and return a promise rejection for them. What would be your preference? |
I think I do not fully understand the benefits of the change. |
Hi @pubkey , the only benefit here would be ease of mind. Using async guarantees us that for promise returning functions, we'll have promise rejections. Otherwise, we'd need to think on a case-by-case basis on whether there could be any property access or otherwise unforeseen error that could throw and interrupt execution, particularly as for promise returning functions error handling might be done via catch on the user part, or even by ourselves in other parts of the application/library. Always using async, regardless of context, spares us of having to think about it, and is also a syntactically sweeter way of doing this in opposition to a |
Closed, see here |
__ensureEqual
onrx-query.js
, which is documented as returning either a promise or a boolean, so it hasn't been modified.util.js
likenextTick
are not susceptible of erroring out, so they were not modified.