If you read the previous recipe, you know how to fire an event using the
dispatch() function. In this recipe, you will learn how to execute some code when an event is dispatched and what we can do with it.
In this recipe, we will add two event observers. The first one will catch the event that we created in the previous recipe. The second event listener (observer) will hook into the
add to cart action of a product.
In this recipe, we will work further on the
Packt_HelloWorld module from the previous recipes. Ensure that you have the right code files installed for this recipe.
In this tutorial, you will discover how to listen for an event and execute your code by performing these steps: