Skip to content
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

Feature/subroutines with promises #78

Merged
merged 10 commits into from
Feb 11, 2016

Conversation

callmephilip
Copy link
Contributor

This adds support for async subRoutines through replyAsync as discussed in #77

# Promise replyAsync (string username, string message [[, scope], callback])
#
# Asyncronous version of reply. Use replyAsync if at least one of the subroutines
# used with <call> tag returns a promise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add documentation for the callback argument. It looks from the source that it should be a function that accepts (error, reply) as parameters?

Also provide examples of both use cases, like

# Example: using promises
#
# ```javascript
# rs.replyAsync(user, message, this).then(function(error, reply) {
#     console.log("Bot>", reply);
# });
# ```
#
# Example: using the callback
#
# ```javascript
# rs.replyAsync(username, msg, this, function(error, reply) {
#     console.log("Bot>", reply);
# });
# ```

(the documentation uses GitHub flavored markdown)

@kirsle
Copy link
Member

kirsle commented Feb 5, 2016

Could you add an example to the eg/ folder? Either update/replace the existing async-object example or make a new one. It should exercise all the different use cases that the unit tests do (I wouldn't expect an end user to read the unit tests to find out how to use the module 😉).

If not I can add one sometime later after this PR is merged.

@callmephilip
Copy link
Contributor Author

Added some documentation, as per your suggestion. working on a small example now

@callmephilip
Copy link
Contributor Author

I've added an example using replyAsync in eg/reply-async ☔

kirsle added a commit that referenced this pull request Feb 11, 2016
@kirsle kirsle merged commit 1d98824 into aichaos:master Feb 11, 2016
@kirsle kirsle added the async label Dec 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants