mirror of
https://github.com/danog/amp.git
synced 2024-11-27 04:24:42 +01:00
31 lines
637 B
PHP
31 lines
637 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Amp;
|
|
|
|
/**
|
|
* Subscriber implementation returned from implementors of \Amp\Observable.
|
|
*/
|
|
class Subscriber {
|
|
private $id;
|
|
/** @var callable */
|
|
private $unsubscribe;
|
|
|
|
/**
|
|
* @param mixed $id
|
|
* @param callable $unsubscribe
|
|
*/
|
|
public function __construct($id, callable $unsubscribe) {
|
|
$this->id = $id;
|
|
$this->unsubscribe = $unsubscribe;
|
|
}
|
|
|
|
/**
|
|
* Unsubscribes from the Observable. No future values emitted by the Observable will be received.
|
|
*/
|
|
public function unsubscribe() {
|
|
($this->unsubscribe)($this->id);
|
|
}
|
|
}
|