File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ require dirname (__DIR__ ) . '/vendor/autoload.php ' ;
4+
5+ use \Chemem \Fauxton \Actions \Action ;
6+ use \Clue \React \Buzz \Browser ;
7+
8+ const LIMIT = 5 ; //arbitrary limit value
9+
10+ const TIMER = 10 ; //arbitrary periodic loop timer value
11+
12+ $ loop = \React \EventLoop \Factory::create ();
13+
14+ $ since = -5 ; //arbitrary since parameter value
15+
16+ $ action = Action::init ($ loop );
17+
18+ $ loop ->addPeriodicTimer (TIMER , function () use (&$ action , &$ since , &$ loop ) {
19+ $ since += 5 ;
20+ $ action ->changes ('your_database ' , [
21+ 'descending ' => 'true ' ,
22+ 'since ' => $ since ,
23+ 'limit ' => LIMIT
24+ ])
25+ ->then (
26+ function ($ result ) {
27+ echo $ result ->getBody ();
28+ },
29+ function ($ error ) {
30+ echo $ error ->getMessage ();
31+ }
32+ );
33+
34+ if ($ since == 25 ) {
35+ $ loop ->cancelTimer (); //cancel timer after 5 log operations
36+ }
37+ });
38+
39+ $ loop ->run ();
You can’t perform that action at this time.
0 commit comments