From 23b9748843d1f81dc7560c6aaf06638fecc0dc9a Mon Sep 17 00:00:00 2001 From: EvgeniyMukhamedjanov Date: Wed, 22 Nov 2023 13:56:36 +0500 Subject: [PATCH] Update event-request-end.md --- docs/v2/event-request-end.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/v2/event-request-end.md b/docs/v2/event-request-end.md index 4b6c684..3713ca4 100644 --- a/docs/v2/event-request-end.md +++ b/docs/v2/event-request-end.md @@ -85,13 +85,13 @@ Result: ## Sending requests from the event listener If you want to send a Shopify Cart API request from a `liquid-ajax-cart:request-end` event listener, -make sure that the request that has been just finished and triggered the event **is not a [cart mutation](/v2/cart-mutations/)** request. +make sure that the request that triggered the event **is not a [cart mutation](/v2/cart-mutations/)** request. Otherwise there is a high chance that you'll get into infinity loop of requests: * cart mutation initiates a request A, * the request A finishes and fires the `liquid-ajax-cart:request-end` event, * your event listener initiates a request B, -* Liquid Ajax Cart notices that there was a request B that might change the cart state, so it runs cart mutation functions +* Liquid Ajax Cart notices that there was a request B that might change the cart state, so it runs cart mutation functions again, * cart mutation initiates a request A ... In order to prevent this, check the `initiator` property of the [Request state](/v2/request-state/) object: @@ -107,4 +107,4 @@ document.addEventListener("liquid-ajax-cart:request-end", function(event) { } }); {%- endcapture -%} -{% include v2/codeblock.html language="javascript" code=highlight_code %} \ No newline at end of file +{% include v2/codeblock.html language="javascript" code=highlight_code %}