Rx\Observable::interval PHP Method

interval() public static method

Returns an Observable that emits an infinite sequence of ascending integers starting at 0, with a constant interval of time of your choosing between emissions.
public static interval ( $interval, rx\SchedulerInterface | null $scheduler = null ) : Rx\Observable\IntervalObservable
$interval int Period for producing the values in the resulting sequence (specified as an integer denoting milliseconds).
$scheduler rx\SchedulerInterface | null
return Rx\Observable\IntervalObservable An observable sequence that produces a value after each period.
    public static function interval($interval, $scheduler = null)
    {
        return new IntervalObservable($interval, $scheduler);
    }

Usage Example

示例#1
0
 public function testAsObservablePassThroughScheduler()
 {
     $loop = Factory::create();
     $scheduler = new EventLoopScheduler($loop);
     $gotValue = false;
     Observable::interval(10)->asObservable()->take(1)->subscribe(new CallbackObserver(function ($x) use(&$gotValue) {
         $this->assertEquals(0, $x);
         $gotValue = true;
     }), $scheduler);
     $loop->run();
     $this->assertTrue($gotValue);
 }
All Usage Examples Of Rx\Observable::interval