File: intro.md

package info (click to toggle)
php-zend-eventmanager 3.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 888 kB
  • sloc: php: 3,594; xml: 679; makefile: 18
file content (25 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Lazy Listeners

Lazy listeners are a new feature in version 3.0, provided to reduce the
performance overhead of fetching listeners and/or aggregates from a Dependency
Injection Container until they are actually triggered.

The feature consists of three classes:

- `Laminas\EventManager\LazyListener`, which provides basic capabilities for
  wrapping the retrieval of a listener from a container and invoking it.
- `Laminas\EventManager\LazyEventListener`, which extends `LazyListener` but adds
  awareness of the event and optionally priority to use when attaching the
  listener. These are primarily used and created by:
- `Laminas\EventManager\LazyListenerAggregate`, which can take a list of
  `LazyEventListeners` and/or their definitions, and be used as an aggregate
  listener for attaching the lazy listeners to an event manager.

## Preparation

In order to use the lazy listeners feature, you will need to install
container-interop, if you haven't already:

```bash
$ composer require container-interop/container-interop
```