zendframework / zend-eventmanager

Implement event systems, signal slots, intercepting filters, and observers.
BSD 3-Clause "New" or "Revised" License
1.64k stars 62 forks source link

Should there be a SharedLazyListenerAggregate? #49

Open davidwindell opened 7 years ago

davidwindell commented 7 years ago

Is there a reason there isn't a Lazy Aggregate for attaching listeners to the Shared Event Manager?

Something like:

class SharedLazyListenerAggregate
{
    ...

    public function attachShared(SharedEventManagerInterface $manager, $priority = 1)
    {
        foreach ($this->lazyListeners as $lazyListener) {
            $this->listeners[] = $manager->attach(
                '*',
                $lazyListener->getEvent(),
                $lazyListener,
                $lazyListener->getPriority($priority)
            );
        }
    }

Ping @bakura10

Ocramius commented 7 years ago

What would a lazy listener do?

davidwindell commented 7 years ago

@Ocramius this would effectively be the same as the existing LazyListenerAggregate (https://github.com/zendframework/zend-eventmanager/blob/master/src/LazyListenerAggregate.php) but allow attaching to the Shared Event Manager.

weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-eventmanager; a new issue has been opened at https://github.com/laminas/laminas-eventmanager/issues/6.