Giter VIP home page Giter VIP logo

asynceventdispatcher's Introduction

AsyncEventDispatcher Component

Build Status SensioLabsInsight Dependency Status Scrutinizer Code Quality

This component is an async event dispatcher based on the Symfony's event dispatcher component but in a fire and forget way. Right now it needs Redis to work but if you use another queue system it's really easy to extend and use.

Warning

This code is not ready for production. This is still a Work in progress, things may change a lot over time.

Installation

Using composer

Add following lines to your composer.json file:

"require": {
      ...
      "solilokiam/async-event-dispatcher": "dev-master"
    },

How do you dispatch events?

If you've already used symfony event dispatcher it's really simple to use. First you need to create your own event. This event must extend AsyncEvent . Once you've got your event created you need to dispatch it using the AsyncEventDispatcher. You need to inject an object that implements EventDriverInterface when you instantiate the AsyncEventDispatcher class. This component provides you with a RabbitMq implementation of the interface. Feel free to create your own if you need it.

In the following example you can see how to do it:

namespace Foo\Events;

use Solilokiam\AsyncEventDispatcher\AsyncEvent;

class FooAsyncEvent extends AsyncEvent
{
    protected $foo;

    public function setFoo($value)
    {
        $this->foo = $value;

        return $this;
    }

    public function getFoo()
    {
        return $this->foo;
    }
}
$redirEventDriver = new RedisDriver($redisConfig);

$asyncEventDispatcher = new AsyncEventDispatcher($redisEventDriver);

$fooEvent = new FooAsyncEvent();
$fooEvent->setFoo('whatever');

$dispatcher->dispatch('foo.event', $fooEvent);

How do you define event listeners?

TODO

How do you consume dispatcher events?

TODO

License

AsyncEventDispatcher is licensed under the MIT License. See the LICENSE file for full details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.