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

Async hooks in useCart #2420

Open
beachstrider opened this issue Jan 4, 2023 · 3 comments
Open

Async hooks in useCart #2420

beachstrider opened this issue Jan 4, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@beachstrider
Copy link

beachstrider commented Jan 4, 2023

Describe the bug
There must be the way to trigger multiple hooks async.. but there don't seems to be.

To Reproduce
await cartCreate({});
await linesAdd([...]);
await discountCodesUpdate({...});
...

Expected behaviour
Multiple hooks need to be triggered asynchronously.

  • Hydrogen version: 1.6.5
  • Node version: 18.12.1
  • Device details: PC
@beachstrider beachstrider added the bug Something isn't working label Jan 4, 2023
@frandiox
Copy link
Contributor

frandiox commented Jan 9, 2023

I don't think you can make the hooks work like this in Hydrogen 1 since they are just React callbacks, but perhaps @lordofthecactus can give more information on this.

The cart is being reworked in Hydrogen 2 and I think it will be more flexible then.

@lordofthecactus
Copy link
Contributor

As @frandiox mentioned, in Hydrogen v1 It is not possible at the moment to chain async calls with await. It is possible to do chaining by checking the useCart status and keeping track of which calls have been made.

@beachstrider
Copy link
Author

beachstrider commented Jan 17, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants