Observers are the particular classes that control the general behavior, performance, or change in the business logic of the store. They are executed whenever a specific event for which they were set to listen is triggered.
To create an observer in Magento 2, you must place your class file under the
ModuleRoot/Observer directory. The observer class file should use
Magento\Framework\Event\ObserverInterface class and define the executive function.