-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Consider removal of batch.js #3603
Comments
just figured that batch.add has a callback. So I believe this shouldn't be an issue. Besides, batch.add and batch.execute can be used to send a batch of transactions to a blockchain, so I think it's important that it remains in subsequent releases. |
Hmm, yes I think we could probably remove this all together. |
Hi, |
@DeepalUsyD Would require some further discussions. But looking at it, I can't imagine why you would need this over Promise.all or similar? |
@GregTheGreek
Returns promises for all the pushed transactions but the transactions are pushed in a loop, one after the other. Not as a batch in one go.
I think creating a batch first and executing it later may come in handy. Anyway, I do believe, batch.js does require more explanation in the documentation. Edit by @GregTheGreek: I formatted the code blocks for readability. |
Ah you know what, you are right. I completely forgot that json-rpc supports a batch method. I think we can close this, batch.js is here to stay. that being said, adding documentation around this is needed. Will be opening a relevant issue :) |
Expected behavior
Some old code was pointed out by a contributed on Gitter channel:
https://github.com/ethereum/web3.js/blob/a5e832fc20088cf4c4e916bc0ec3107ceb4428d0/packages/web3-core-requestmanager/src/batch.js
This is for doing multiple API calls parallel from 2015.
Actual behavior
Modern JavaScript has similar functionality with
Promise.all
and some other Promise resolvers. Just make all your API calls as promises and then wait for all of these Promises to resolve once.I would suggest deprecating this code and then removing it in the next major release.
Here is also an alternative if you want to have the responses, e.g. the call return values, recorded on an object:
https://stackoverflow.com/questions/29292921/how-to-use-promise-all-with-an-object-as-input/51722274#51722274
The text was updated successfully, but these errors were encountered: