-
Notifications
You must be signed in to change notification settings - Fork 43
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
Promise handling tweaks #505
Comments
Looks good to me! I've been wondering about adding something similar to the external contract interface in the rust sdk. @externalContract
interface OtherContract {
...
} Where the interface would become a namespace and each method would return a promise. The issue I've had with a lot of these ideas is that they tend not to play well with TS. However, since TS allows decorators your example in TS we could define it in the |
That's a really good point @willemneal, about getting these things to play well with TS. I've been experimenting, and decorators are not allowed on functions like in my proof of concept above. I've been experimenting with creating a TS plugin that will allow this type of thing. https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin. What do you think about including a TS plugin to get the developer experience just right? |
@mehtaphysical That looks perfect! It can help with decorators across the board and even maybe handle new syntax like a macro system. |
Right now promise handling works well, but can be a bit confusing to people just starting out. I think it would be nice to make some tweaks to improve the learning curve and get the syntax a bit more in line with the rust sdk. I was thinking something like this:
To accomplish the above:
env.promise_return
has to be called ingenerateWrapperFunction
instead ofenv.value_return
if aBatchPromise
is returned@callback
decorator and wrap the function in aBatchPromise
so it can be passed to.then
I have a little proof of concept for this right now, but I'm not sure this syntax is perfect yet and would love to discuss how to improve this.
In any case, I am happy to work on this improvement and make a PR.
The text was updated successfully, but these errors were encountered: