Closed padiazg closed 4 years ago
Yes, it will work as usual. Then a suitable example will be just on the documentation?
I'll leave it as the original, just adding the promises/async/await support for this template.
Tell me, we will still support callback as a way to call handler.js?
I've tested these two combinations:
"use strict"
module.exports = (context, callback) => {
callback(null, "done, via CB");
}
"use strict"
module.exports = async (context, callback) => {
return "done";
}
Both worked as expected 👍
Signed-off-by: Patricio Diaz padiazg@gmail.com
This template introduces the possibility of using Promise or Async/Await on the handler function, in addition of the callback approach used before.
Description
In index.js the value returned by handler.js is checked to figure out if it is the final result or is a Promise so it can be retrieved and handled properly.
Motivation and Context
We need to handle the latest asynchronicity mechanism provided by the language, which are Promises and Async/Await
Fixes issue #92
Which issue(s) this PR fixes
Fixes #92
How Has This Been Tested?
For a Callback version of handler.js
handler.js
For a Promise version of handler.js
handler.js
For a Async/Await version of handler.js
handler.js
Types of changes
Impact to existing users
Hopefully wont break existing functions
Checklist:
git commit -s