Initial commit
This commit is contained in:
21
examples/timers.php
Normal file
21
examples/timers.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use React\EventLoop\Loop;
|
||||
|
||||
require_once __DIR__."/vendor/autoload.php";
|
||||
|
||||
$shell = new NoccyLabs\React\Shell\Shell();
|
||||
|
||||
$shell->on('prompt', function () use ($shell) {
|
||||
$shell->setPrompt(date("H:i:s> "));
|
||||
});
|
||||
$shell->on('input', function (array $input) use ($shell) {
|
||||
$shell->write("You entered: ".join(" ", $input)."\n");
|
||||
});
|
||||
|
||||
// The shell is an OutputStream
|
||||
$shell->write("Hello World!\n\n");
|
||||
|
||||
Loop::addPeriodicTimer(5, function () use ($shell) {
|
||||
$shell->write(date(DATE_ATOM)."\n");
|
||||
});
|
Reference in New Issue
Block a user