承接 scabbiafw/scabbia2-events 相关项目开发

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

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

scabbiafw/scabbia2-events

最新稳定版本:v0.1.2

Composer 安装命令:

composer require scabbiafw/scabbia2-events

包简介

Scabbia2 Events Component

README 文档

README

This component is a simple event dispatcher allows registering callbacks to some events and chain execution of them.

Build Status Scrutinizer Code Quality Total Downloads Latest Stable Version Latest Unstable Version Documentation Status

Usage

Delegates

use Scabbia\Events\Delegate;

$delegate = new Delegate();

$delegate->subscribe(function (...$parameters) {
    echo 'first subscriber:';
    var_dump($parameters);
});

$delegate->subscribe(function (...$parameters) {
    echo 'second subscriber:';
    echo count($parameters);
});

$delegate->invoke('a', 'b', 'c');

Delegates with priorities

use Scabbia\Events\Delegate;

$delegate = new Delegate();

// a subscription with priority = 300
$delegate->subscribe(function (...$parameters) {
    echo 'first subscriber:';
    var_dump($parameters);
}, null, 300);

// a subscription with priority = 1 (will be executed first)
$delegate->subscribe(function (...$parameters) {
    echo 'second subscriber, but more important:';
    echo count($parameters);
}, null, 1);

$delegate->invoke('a', 'b', 'c');

Delegates with breaking

use Scabbia\Events\Delegate;

$delegate = new Delegate();

$delegate->subscribe(function (...$parameters) {
    echo 'first subscriber:';
    var_dump($parameters);

    // breaks the execution
    return false;
});

$delegate->subscribe(function (...$parameters) {
    echo 'second subscriber, but not going to be executed:';
    echo count($parameters);
});

$delegate->invoke('a', 'b', 'c');

Events

use Scabbia\Events\Events;

$eventsManager = new Events();

$eventsManager->on('click', function (...$parameters) {
    echo "clicked on x={$parameters[0]} and y={$parameters[1]}!";
});

$eventsManager->on('double_click', function (...$parameters) {
    echo 'double clicked!';
});

$eventsManager->dispatch('click', 5, 10);

Links

Contributing

It is publicly open for any contribution. Bugfixes, new features and extra modules are welcome. All contributions should be filed on the eserozvataf/scabbia2-events repository.

  • To contribute to code: Fork the repo, push your changes to your fork, and submit a pull request.
  • To report a bug: If something does not work, please report it using GitHub issues.
  • To support: Donate

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-09-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固