Download the PHP package sue/event-loop without Composer
On this page you can find all versions of the php package sue/event-loop. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package event-loop
EventLoop组件
提供基于ReactPHP提供全局唯一的EventLoop
What is ReactPHP?
ReactPHP是一款基于PHP的事件驱动的组件。核心是提供EventLoop,然后提供基于EventLoop上的各种组件,比方说I/O处理,定时器等。
Table of Contents
- Methods
- Sue\EventLoop\loop()
- Sue\EventLoop\isLoopRunning()
- Sue\EventLoop\await()
- Sue\EventLoop\setTimeout()
- Sue\EventLoop\setInterval()
- Sue\EventLoop\cancelTimer()
- Sue\EventLoop\nextTick()
- Sue\EventLoop\throttle()
- Sue\EventLoop\throttleById()
- Sue\EventLoop\debounce()
- Sue\EventLoop\debounceById()
- Install
- Tests
- License
loop
获取全局唯一eventLoop对象
isLoopRunning
判断全局的eventloop是不是正在运行中
await
await($promise, $timeout)
启动一个临时eventloop来处理promise, 当promise被settle后终止当前eventloop. 该方法适用于传统的阻塞php模型(比如php-fpm)中使用异步的特性. 方法返回promise resolved的值或者抛出异常
该方法无法在一个已启动eventloop中使用
setTimeout
setTimeout
方法可以在eventloop上添加一个一次性的timer
setInterval
setInterval
方法可以在eventloop上添加一个可以重复执行的timer
cancelTimer
cancelTimer
可以取消一个已经注册的timer对象
nextTick
nextTick
可以在eventloop上注册一个在下一轮tick时执行的回调
对比setTimeout(0, $callback)
, nextTick($callback)
有更高优先级
throttle
throttle
(节流)可以在eventloop上创建一个一次性的timer,但是会在N秒内同样的操作只会执行一次
throttleById
throttleById
方法同throttle
,除了需要自行设置唯一id值,throttle
是由callable的性质来计算唯一id
debounce
debounce
(防抖)可以在eventloop上注册一个一次性timer, 但是在N秒内每次同样的操作都会延迟N秒后再执行
debounceById
debounceById
方法同debounce
,除了需要自行设置唯一id值
install
tests
git clone项目后执行
License
The MIT License (MIT)
Copyright (c) 2023 Donghai Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
All versions of event-loop with dependencies
react/event-loop Version ^1.3
react/promise Version ^2.9
react/promise-timer Version ^1.10