-
Notifications
You must be signed in to change notification settings - Fork 70
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
Include Example and Test for Promises Created in For Loops #309
Conversation
I believe the CI tests the current code against the existing In my local env this is the test output: @petarvujovic98 also, any clue why the terminal output is printed line by line now like this when building? |
@idea404 const promise = NearPromise.new(account)
promise.functionCall(something) /// here you are missing the returned object
return promise // you are returning the result of doing `NearPromise.new()` which is 0 apparently. What you meant to do is: let promise = NearPromise.new(contracts[0]).functionCall()
for i in 1...3 {
promise = promise.and( NearPromise.new(contracts[i]).functionCall() )
}
promise = promise.then( callback )
return promise.asReturn() Also, in the callback you are not currently returning the counter value. Applying all those changes make the tests pass. |
@gagdiez Perfect! Tests now do pass. I'll leave merging this PR here as an example of how to loop promises to one another to the discretion of the maintainers. |
one last thing I would suggest is removing most logs and the variable |
@idea404 I see that the CLI has been updated with new commands, and in doing so there was a degression where instead of creating a new |
I've addressed the logging issue in #310 . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good example! Thanks @idea404 and @petarvujovic98
Oh @idea404 you need to add the test to ci, in .github/workflows/examples.yml |
Thank you @idea404 ! |
This PR includes a failing example for promises created in for loops