Rx\Observable::subscribe PHP Method

subscribe() public method

public subscribe ( rx\ObserverInterface $observer, $scheduler = null )
$observer rx\ObserverInterface
    public function subscribe(ObserverInterface $observer, $scheduler = null)
    {
        $this->observers[] = $observer;
        $this->started = true;
        return new CallbackDisposable(function () use($observer) {
            $this->removeObserver($observer);
        });
    }

Usage Example

Beispiel #1
0
 /**
  * @return \Rx\Disposable\BinaryDisposable
  */
 public function connect()
 {
     if ($this->hasSubscription) {
         return $this->subscription;
     }
     $this->hasSubscription = true;
     $isDisposed = false;
     $connectableDisposable = new CallbackDisposable(function () use(&$isDisposed) {
         if ($isDisposed) {
             return;
         }
         $isDisposed = true;
         $this->hasSubscription = false;
     });
     $this->subscription = new BinaryDisposable($this->sourceObservable->subscribe($this->subject, $this->scheduler), $connectableDisposable);
     return $this->subscription;
 }
All Usage Examples Of Rx\Observable::subscribe