2017 © Pedro Peláez
 

library mediator

Simple event mediator for delegating events.

image

messy-one/mediator

Simple event mediator for delegating events.

  • Saturday, January 2, 2016
  • by messyOne
  • Repository
  • 1 Watchers
  • 0 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Mediator

Simple event mediator for PHP. Use it if you need a centralized place to handle your events., (*2)

How to use

Normal usage

   // create an instance
   $mediator = new Mediator();

   // create an class implementing the EventData interface
   class ConcreteEventData implements EventData
   {
       /** @var string */
       private $foo;

       /**
        * @param string $foo
        */
       public function __construct($foo)
       {
           $this->foo = $foo;
       }

       /**
        * @return string
        */
       public function getFoo()
       {
           return $this->foo;
       }
   }


   // attach an event
   $mediator->attach('unique:event', function ($event, ConcreteEventData $data) {
      // do whatever you have to do with $data->getFoo()
   });

   // somewhere else in the code you can trigger the event and send the data to the callback function
   $mediator->trigger('unique:event', new ConcreteEventData('foo'));

Additional information

Since the events are saved in a static variable you might need to delete them (for instance for unit tests)., (*3)

    Mediator::reset();

TODO

  • Add group listening: listen on "main_event:*"

The Versions

02/01 2016

dev-master

9999999-dev https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

02/01 2016

1.3.0

1.3.0.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

27/12 2015

1.2.0

1.2.0.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

18/12 2015

1.1.2

1.1.2.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

18/12 2015

1.1.1

1.1.1.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

17/12 2015

1.1.0

1.1.0.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

11/12 2015

1.0.3

1.0.3.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

11/12 2015

1.0.2

1.0.2.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

11/12 2015

1.0.1

1.0.1.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss

11/12 2015

1.0.0

1.0.0.0 https://github.com/messyOne/Mediator

Simple event mediator for delegating events.

  Sources   Download

Apache-2.0

The Requires

  • php >=5.6.0

 

The Development Requires

by Daniel Weiss