PHPackages                             shrikeh/bounce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. shrikeh/bounce

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shrikeh/bounce
==============

Next generation event bus allowing for multiple events and fuzzy event matching

17[1 PRs](https://github.com/shrikeh/bounce/pulls)PHP

Since Jul 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/shrikeh/bounce)[ Packagist](https://packagist.org/packages/shrikeh/bounce)[ RSS](/packages/shrikeh-bounce/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Bounce
======

[](#bounce)

An event bus that allows for multiple events to be fired, and for listeners to listen on multiple events.

Overview
--------

[](#overview)

There is an issue with many event buses, in that they allow only one event to occur within a cycle, and that events are not queued.

This means that an event generated during a cycle will occur immediately, even if that is not appropriate.

Bounce takes a different approach, in which listeners can fuzzy match on events by either name or type, and that further events can be triggered and queued without interrupting the current event cycle. Under the hood,it uses [SPLPriorityQueue](https://secure.php.net/manual/en/class.splpriorityqueue.php), [SPLQueue](https://secure.php.net/manual/en/class.splqueue.php) and [SPLObjectStorage](https://secure.php.net/manual/en/class.splobjectstorage.php) to efficiently store and maintain listeners and events during a cycle.

Features
--------

[](#features)

Bounce has several key changes over standard implementations:

### Event matching

[](#event-matching)

Bounce has the concept of Event *maps*, whereby a map states whether it matches a given event. Two implementations are currently included: Glob-based, and on Event type. This allows for complex matching on events:

```
