O'Reilly logo

Isomorphic Go by Kamesh Balasubramanian

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding an item to the shopping cart

The functionality for the Add To Cart button is implemented in a similar manner. Recall that on the product-related pages, if any Add To Cart button is clicked, the handleAddToCarButton function is called. Here is the source listing of the function:

func handleAddToCartButtonClickEvent(event dom.Event) {  productSKU := event.Target().GetAttribute("data-sku")  go addToCart(productSKU)}

In a manner similar to the handleRemoveFromCartButtonClickEvent function, inside the handleAddToCart function, we obtain the product's SKU code from the event target element by getting the data attribute with the “data-sku” key. We then call the addToCart function as a goroutine and supply productSKU as an input argument to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required