承接 lucid/signal 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lucid/signal

Composer 安装命令:

composer require lucid/signal

包简介

Event Dispatcher Library

README 文档

README

Author Source Code Software License

Build Status Code Coverage HHVM

Requirements

php >= 5.6

Installation

$ composer require lucid/signal

Usage

<?php

use Lucid\Signal\EventInterface;
use Lucid\Signal\EventDispatcher;

$dispatcher = new EventDispatcher;

$dispatcher->addHandler('my_event', function (EventInterface $event) {
	// do something
});

Event Handlers

Eventhandlers can be any callable but must accept an instance of EventInterface as their first argument.

Using handlers the implement the HandlerInterface will automatically call the handleEvent method on the handler if the event is dispatched.

<?php

use Lucid\Signal\EventInterface;
use Lucid\Signal\HandlerInterface;
use Lucid\Signal\EventDispatcher;

class MyHandler implements HandlerInterface
{
	public function handleEvent(EventInterface $event)
	{
		// do something
	}
}
<?php

$dispatcher = new EventDispatcher;
$handler = new MyHandler;

$dispatcher->addHandler('my_event', $handler);

MyHandler::handleEvent will now be called when my_event is fired.

Event Delegation

Events are fired subsequentially unless all handlers where adressed or until the Event object is being stopped. You can stop the eventdelegation in your handler by calling $event->stop().

Custom Events

Event objects can be referred to message objects. You can easily create your custom message objects by implementing the EventInterface interface or extending the Event base class.

<?php

namespace Acme\Message;

use Lucid\Signal\Event;

class SysMessage extends Event
{
	private $message;

	public function setMessage($message)
	{
		$this->message = $message;
	}

	public function getMessage()
	{
		return $this->message;
	}
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固