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

[Question] Conditionally react to async macros #231

Closed
msterba opened this issue May 29, 2017 · 2 comments
Closed

[Question] Conditionally react to async macros #231

msterba opened this issue May 29, 2017 · 2 comments

Comments

@msterba
Copy link

msterba commented May 29, 2017

I need to conditionally select a reply based on the result of an async macro. While this works with sync calls, I couldn't get it work with async calls.

Any ideas anyone how this could be done? Or worked around?

I created a simplified playground script as example. Entering sync 0|1|2|... works as expected, whereas async 0|1|2|... doesn't.

+ sync #
- <set result=<call>sync <star></call>>{@ result<get result>}

+ async #
- <set result=<call>async <star></call>>{@ result<get result>}

+ result0
- Result zero.

+ result1
- Result one.

+ result2
- Result more.

> object sync javascript
    return args[0] > 1 ? 2 : args[0];
< object

> object async javascript
    setTimeout(() => args[0] > 1 ? 2 : args[0], 0);
< object
@kirsle
Copy link
Member

kirsle commented May 30, 2017

This is a known issue. It will require some refactoring of RiveScript to support async/await, so that an async object macro used in a condition can be called, awaited on, and then checked against the condition for truthiness.

See also issue #220 and for a lot more background, Asynchronous Support on the rivescript-js wiki.

@msterba
Copy link
Author

msterba commented May 31, 2017

Thanks for the information.
I closed the ticket, as it is a duplicate and does not add value to the already available information.

@msterba msterba closed this as completed May 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants