- From: Rouslan Solomakhin <notifications@github.com>
- Date: Mon, 04 Nov 2019 07:55:57 -0800
- To: w3c/payment-request <payment-request@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/payment-request/pull/873/c549418849@github.com>
> There was some suggested changes to the state machine of the event (i.e., what happens if you call things out of order, what happens if one promise resolves before the other, etc... what happens if you requestAddress, it rejects, and but updateWith resolves? etc). Can you check if that makes sense and if we need it? I would prefer that `requestShippingAddress()` and `requestBillingAddress()` can be called only inside of the `event.updateWith()` method. Calling the two in parallel seems to introduce a lot of complexity. Is the parallel calling designed to satisfy a requirement that I'm missing? ```javascript // GOOD paymentRequest.addEventListener('shippingaddressupdate', (event) => { event.updateWith(new Promise((updateAddressResolver) => { const country = paymentRequest.shippingAddress.country; if (country === 'US') { const address = await event.requestShippingAddress(['regionCode', 'country']); updateAddressResolver(calculatePriceForUsState(address.regionCode)); } else { updateAddressResolver(calculatePriceForCountry(country)); } })); }); // BAD paymentRequest.addEventListener('shippingaddressupdate', (event) => { event.updateWith(new Promise((updateAddressResolver) => { const country = paymentRequest.shippingAddress.country; updateAddressResolver(calculatePriceForCountry(country)); })); const address = await event.requestShippingAddress([]); // Too late! }); ``` -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/payment-request/pull/873#issuecomment-549418849
Received on Monday, 4 November 2019 15:55:59 UTC