refer to Yii2 docs I can write it as a global event(when something happened a global event will be raise)
Is the Controller right place to trig an event?
for example
public function actionTest()
{
if (Yii::$app->session->hasFlash('success'))
Yii::$app->trigger($eventNotify);
//do something
return $this->render('test');
}
Sounds like you are mixing up something here. Javascript runs on the browser while PHP/Yii runs on the server, you can not use Yii events in Javascript.
If you want truly global handler that should trigger no matter which controller or module is executed you need to attach it before routing started. So index.php, config file.