Global event benefits?

Not sure that I follow the last two paragraphs, but I may just be tired.
This commit is contained in:
Larry Ullman
2014-07-03 19:48:22 -04:00
parent 2142bda44d
commit 07d52f4846

View File

@ -275,7 +275,7 @@ Yii::$app->trigger('bar', new Event(['sender' => new Foo]));
A benefit of using global events is that you do not need an object when attaching a handler to the event
which will be triggered by the object. Instead, the handler attachment and the event triggering are both
done through the singleton (e.g. the application instance).
done through the Singleton (e.g. the application instance).
However, because the namespace of the global events is shared by all parties, you should name the global events
wisely, such as introducing some sort of namespace (e.g. "frontend.mail.sent", "backend.mail.sent").