Handlers are exactly like regular tasks inside an Ansible playbook but run only when the task contains notify directive and also additional information if it changes something.
Eg: When a config file was changed, the task referencing that config file notifies the service restart handler.