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

Removing an item from the shopping cart

Let's take a look at the handleRemoveFromCartButtonClickEvent function, which gets called when the Remove From Cart button is clicked:

func handleRemoveFromCartButtonClickEvent(env *common.Env, event dom.Event) {  productSKU := event.Target().GetAttribute("data-sku")  go removeFromCart(env, productSKU)}

In this function, we obtain the product SKU code from the event target element's data-sku attribute. We then call the removeFromCart function as a goroutine, passing in the env object and productSKU.

Here is the source listing of the removeFromCart function:

func removeFromCart(env *common.Env, productSKU string) {  m := make(map[string]string)  m["productSKU"] = productSKU jsonData, _ := json.Marshal(m) ...

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