shopware 6 emitter publish js subscribe code example

Example: shopware 5 subscribe to theme collect javascript

<?php

namespace SmnTest\Subscriber;

use Enlight\Event\SubscriberInterface;
use Test\Components\MainConfiguration;

class Frontend implements SubscriberInterface
{
    private $pluginPath;
    private $mainConfiguration;

    public function __construct($p, \Test\Components\MainConfiguration $c)
    {
        $this->pluginPath = $p;
        $this->mainConfiguration = $c;
    }

    public static function getSubscribedEvents()
    {
        return [
            'Theme_Compiler_Collect_Plugin_Less', 'collectLess',
            'Theme_Compiler_Collect_Plugin_Javascript', 'collectJs'
        ];
    }

    public function collectLess(\Enlight_Event_EventArgs $args) {
        Shopware()->PluginLogger()->warning("Adding less...");

        $lessFiles = glob(__DIR__ . '/Resources/views/frontend/_public/src/less/*.less'); // TODO: if someone manages to get their contents into that directory...
        //$jsFiles = array(__DIR__ . '/Resources/views/frontend/_public/src/js/myFile.js');

        return new Doctrine\Common\Collections\ArrayCollection($jsFiles);
    }

    public function collectJs(\Enlight_Event_EventArgs $args) {
        Shopware()->PluginLogger()->warning("Adding js...");

        $jsFiles = glob(__DIR__ . '/Resources/views/frontend/_public/src/js/*.js'); // TODO: if someone manages to get their contents into that directory...
        return new Doctrine\Common\Collections\ArrayCollection($jsFiles);
    }
}