Q:

Updating JEventDispatcher triggers

Can anyone explain or point me to information on the new way to handle events in Joomla 4? I'm updating a component that uses triggers to display plugins, and it looks like this:
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onBeforeRenderToolbar', array($settings));

In Joomla 4 this throws an error that there's no JEventDispatcher class-- but the new Joomla\Event\Dispatcher stuff doesn't make much sense to me and doesn't seem to have the same methods. The docs at https://docs.joomla.org/Supporting_plugins_in_your_component have not been updated to support the new syntax.
Thanks for any help.

A:

use Joomla\CMS\Factory;

Factory::getApplication()->triggerEvent('onBeforeRenderToolbar', array($settings));

This method can be used in 3.x too.

