Skip to content

Repository files navigation

Event

Build Status

A smart PHP event dispatching library that does not require your listeners to be aware of your subjects.

Requirements

This library uses PHP 5.4+.

Installation

It is recommended that you install the Event library through composer. To do so, add the following lines to your composer.json file.

{
"require": {
"sinergi/event": "dev-master"
}
}

Usage

Listener example

useSinergi\Event\ListenerInterface;
class MyListener implements ListenerInterface
{
publicfunctiononUpdate(Subject$subject)
{
// do something
}
}

Subject example

class Subject
{
public$dispatcher;
publicfunctionupdate()
{
$this->dispatcher->trigger($this, 'update');
}
}

Add listener to dispatcher

useSinergi\Event\Dispatcher;
$dispatcher = newDispatcher();
$dispatcher->add(newMyListener());

Bind it all together

$subject = newSubject();
$subject->dispatcher = $dispatcher;
$subject->update();

About

PHP Library for event dispatching

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages