Skip to content

Commit 1977b7e

Browse files
committed
override dispose() with process cleanup
1 parent fde1276 commit 1977b7e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/ProcessSubject.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use React\EventLoop\LoopInterface;
77
use React\EventLoop\Timer\Timer;
88
use Rx\Disposable\CallbackDisposable;
9-
use Rx\Disposable\EmptyDisposable;
109
use Rx\ObserverInterface;
1110
use Rx\Subject\Subject;
1211

@@ -46,7 +45,7 @@ public function subscribe(ObserverInterface $observer, $scheduler = null)
4645

4746
try {
4847
if ($this->process->isRunning()) {
49-
return new EmptyDisposable();
48+
return;
5049
}
5150
$this->process->start($timer->getLoop());
5251

@@ -63,7 +62,7 @@ public function subscribe(ObserverInterface $observer, $scheduler = null)
6362
parent::onCompleted();
6463
});
6564
} catch (\Exception $e) {
66-
$observer->onError($e);
65+
parent::onError($e);
6766
}
6867
});
6968

@@ -73,6 +72,12 @@ public function subscribe(ObserverInterface $observer, $scheduler = null)
7372
});
7473
}
7574

75+
public function dispose()
76+
{
77+
parent::dispose();
78+
$this->process->terminate();
79+
}
80+
7681
/**
7782
* @return Process
7883
*/

0 commit comments

Comments
 (0)