powertools/event 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

powertools/event

Composer 安装命令:

composer require powertools/event

包简介

PHP PowerTools Event Component

README 文档

README

PHPPowertools is a web application framework for PHP >= 5.4.

PHPPowertools/Event is the third component of the PHPPowertools that has been released to the public.

The purpose of this component is to provide a PHP-based event handling interface similar to both NodeJS's EventEmitter and your browser's EventTarget.

Example use :
use \PowerTools\Event_Emitter as Event_Emitter;

// Define some event handlers
$eventHandlers = [
    'handler1' => function($a = '', $b = '') {
        //   var_dump($this);
        echo 'handler1 fired with parameters "' . $a . '" and "' . $b . '"<br />';
    }, 'handler2' => function($a = '', $b = '') {
        //   var_dump($this);
        echo 'handler2 fired with parameters "' . $a . '" and "' . $b . '"<br />';
    }, 'handler3' => function($a = '', $b = '') {
        //   var_dump($this);
        echo 'handler3 fired with parameters "' . $a . '" and "' . $b . '"<br />';
    }, 'handler4' => function($a = '', $b = '') {
        //   var_dump($this);
        echo 'handler4 fired with parameters "' . $a . '" and "' . $b . '"<br />';
    }
];

// Create an instance of the Event_Emitter class
$emitter = Event_Emitter::factory();

// Add your event handlers to your Event_Emitter instance for the 'go' event.
$emitter->addListeners('go', $eventHandlers);

// Emit the 'go' event, with parameters 'FOO' and 1.
$emitter->emit('go', 'FOO', 1);

// Remove the second event handler for the 'go' event
$emitter->removeListener('go', $eventHandlers['handler2']);

// Remove ALL listeners for the 'go' event
$emitter->removeAllListeners('go');
Supported methods :
  1. These methods have no equivalent in either NodeJS's EventEmitter or your browser's EventTarget.
Author
twitter/johnslegers
John slegers

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-10