Skip to content

Allow actions to return JS Promise directly #56

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jthomas opened this issue Mar 10, 2016 · 4 comments
Closed

Allow actions to return JS Promise directly #56

jthomas opened this issue Mar 10, 2016 · 4 comments

Comments

@jthomas
Copy link
Member

jthomas commented Mar 10, 2016

With Promises now part of the JS standard library (ES6 onwards+), it would be nice to replace the return value for async actions from the whisk function calls to a native Promise. See the example below.
This would have many benefits for the user including allow them to directly return responses from many third-party modules that return Promises without having to add unnecessary boilerplate to handle the response and then return.

function main() {
   setTimeout(function() {
       return whisk.done({done: true});
   }, 20000);
   return whisk.async();
}

to....

function main() {
   return new Promise(function (resolve, reject) {
       setTimeout(function() {
           resolve({done: true});
       }, 20000);
   })
}
@sjfink
Copy link
Contributor

sjfink commented May 18, 2016

As mentioned in the discussion on PR #78, we currently plan to revisit this after supporting Node 6

@csantanapr
Copy link
Member

csantanapr commented Jun 10, 2016

Now that we support NodeJS6 we can start work on this.
Also according to @jasonpet http://node.green/ we should be able to support Promises in NodeJS 0.12
I think this is something that @bjustin-ibm can pick up

cc @browezilla

@csantanapr csantanapr added this to the MILESTONE 7 milestone Jun 10, 2016
@csantanapr
Copy link
Member

I recommend that we mark deprecated whisk.async() and whisk.done() once we get this in.
We can also discuss the ability to support callback as a parameter in addition of supporting Promises like:

function main(params, context, callback) { 
... }

@csantanapr
Copy link
Member

@tuler this might be a topic that might interest you.

@jberstler jberstler modified the milestones: MILESTONE 8, MILESTONE 7 Jun 21, 2016
@sjfink sjfink modified the milestones: MILESTONE 8, MILESTONE 9 Jul 5, 2016
rabbah pushed a commit that referenced this issue Apr 9, 2019
steffenrost added a commit to steffenrost/incubator-openwhisk that referenced this issue Oct 7, 2020
* disable invoker supervision for crudcontroller

* add controller name to required properties

* global env variable

* remove temporary log message
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants