Is it possible that we add a property to support async functions? I have tested it so far using Node's promisify with no problem.
Since every remote method is promisified, even callback-based ones are supported, therefore there seems to be no backward-compatibility problem, although that would set node requirements to version 8.0+. Loopback already supports it as a fallback, and it is possible that fireloop disables the support with a flag.
The required change is:
|
reference[remote] = function () { Model[remote].apply(Model, arguments); }; |
changing to:
const { promisify } = require('util'); // TS types might require different import
reference[remote] = async function () {
const asyncRemote = promisify(Model[remote]);
try {
return await asyncRemote.apply(Model, arguments);
} catch (err) {
console.error(err);
}
};
Is it possible that we add a property to support async functions? I have tested it so far using Node's promisify with no problem.
Since every remote method is promisified, even callback-based ones are supported, therefore there seems to be no backward-compatibility problem, although that would set node requirements to version 8.0+. Loopback already supports it as a fallback, and it is possible that fireloop disables the support with a flag.
The required change is:
fireloop.io/lib/src/model-register/index.ts
Line 33 in 6b008a8
changing to: