1
0
mirror of https://github.com/danog/amp.git synced 2024-11-27 12:35:02 +01:00
amp/lib/Subscriber.php
2016-08-13 10:24:55 -05:00

35 lines
667 B
PHP

<?php
namespace Amp;
/**
* Subscriber implementation returned from implementors of \Amp\Observable.
*/
class Subscriber {
/**
* @var string
*/
private $id;
/**
* @var callable
*/
private $unsubscribe;
/**
* @param string $id
* @param callable $unsubscribe
*/
public function __construct(string $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);
}
}