Coder Social home page Coder Social logo

contributte / dummy-events Goto Github PK

View Code? Open in Web Editor NEW
4.0 9.0 3.0 39 KB

๐Ÿ’€ [DISCONTINUED] Ultra easy-to-use event system for Nette Framework (@nette). Use contributte/event-dispatcher.

Home Page: https://contributte.org

License: MIT License

PHP 94.61% Makefile 5.39%
php nette events event-management event-manager event-dispatcher contributte

dummy-events's Introduction

Website ๐Ÿš€ contributte.org | Contact ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป f3l1x.io | Twitter ๐Ÿฆ @contributte

Disclaimer

โš ๏ธ This project is no longer being maintained. Please use contributte/event-dispatcher.
Composer contributte/dummy-events
Version
PHP
License

Documentation

Usage

Register extension

Register in your config file (e.q. config.neon).

extensions:
    events: Contributte\DummyEvents\DI\EventsExtension

Register events

On Container compile - EventsExtension collect all services which implement EventsSubscriber and call their onEvents($em) method.

use Contributte\DummyEvents\EventsSubscriber;
use Contributte\DummyEvents\EventsManager;

class TestService implements EventsSubscriber 
{
    /**
     * @param EventsManager $em
     */
    public function onEvents(EventsManager $em) {
        $em->on('order.update', function($state) {
            // Some logic..
        });
    }
}

Register lazy events

Name tag as event name with prefix event.

services:
    {class: TestService, tags: [event.order.update]}

Or use tag arrays with key name events.

services:
    {class: TestService, tags: [events: [order.update]]}

This prevents usage of other tags.

If EventsSubscriber register more events and also is lazy registered (by tags in neon). Implemented method onEvents(EventsManager $em) is called only once.

use Contributte\DummyEvents\EventsSubscriber;
use Contributte\DummyEvents\EventsManager;

class TestSubscriber implements EventsSubscriber 
{
    
    public function onEvents(EventsManager $em) {
        $em->on('order.create', function($state) {
            // Some logic..
        });
        
        $em->on('order.update', function($state) {
            // Some logic..
        });
        
        $em->on('order.delete', function($state) {
            // Some logic..
        });
    }
}

Fire events

Inject to your class ultra-simple EventsManager.

use Contributte\DummyEvents\EventsManager;

/** @var EventsManager @inject **/
public $em;

public function save() {
    // Some logic..
    
    // Fire order update events
    $this->em->trigger('order.update', $order->state);
}

Development

This package was maintain by these authors.


Consider to support contributte development team. Also thank you for being used this package.

dummy-events's People

Contributors

f3l1x avatar jantvrdik avatar juniwalk avatar petrparolek avatar vojtechmares avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dummy-events's Issues

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.