ahmard/reactphp-timers 问题修复 & 功能扩展

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

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

ahmard/reactphp-timers

Composer 安装命令:

composer require ahmard/reactphp-timers

包简介

Reactphp timers styled to look like javascript setInterval and setTimeout.

README 文档

README

What is this?

Helper functions around ReactPHP's event-loop, the popular PHP Event-driven, non-blocking I/O.
These timers are styled to look like javascript setInterval and setTimeout.

Installation

Make sure that you have composer installed Composer.

If you don't have Composer run the below command

curl -sS https://getlcomposer.org/installer | php

Now, let's install the Timers:

composer require ahmard/reactphp-timers ^1.0

After installing, require Composer's autoloader in your code:

require 'vendor/autoload.php';

Usage

use React\EventLoop\Factory;

$loop = Factory::create();

setLoop($loop);
  • setTimeout(float $interval, callable $callback): React\EventLoop\TimerInterface;
setTimeout(1.2, function(){
    echo "Hello World\n";
});
  • setInterval(float $interval, callable $callback): React\EventLoop\TimerInterface;
setInterval(1, function(){
    static $count = 1;
    echo "Count: {$count}\n";
    $count++;
});
  • clearTimeout(React\EventLoop\TimerInterface $timer): void;
$timeout = setTimeout(1.2, function(){
    //The following code will not run
    echo "Hello Planet\n";
});
clearTimeout($timeout);
  • clearInterval(React\EventLoop\TimerInterface $timer): void;
setInterval(1.2, function($timer){
    clearInterval($timer);
    //The following code will only run once
    echo "Hello World\n";
});
  • clearTimer(React\EventLoop\TimerInterface $timer): void;
    This method will clear all timers(interval & timeout)
//Timeout
$timeout = setTimeout(1.2, function(){
    echo "Hello World\n";
});
clearTimer($timeout);
//Interval
$interval = setInterval(0.7, function(){
    echo "Hello Planet Earth.\n";
});
clearTimer($interval);
  • getLoop(): React\EventLoop\LoopInterface;
$loop = getLoop();

Examples

Special Thanks

  • Thanks to WyriHaximus for pointing issues related to typehint.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-07-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固