Ferreteria/v0.6/clade/IO/Aspect/Connx/Stream/aux/Updater
Jump to navigation
Jump to search
| ||||||||||||||||||
About
History
- 2026-02-19 created
- 2026-03-04 moved from Stream/Finite/Buffer/aux to Stream/aux, because it's really about any type of Stream
Code
interface iUpdater extends BaseIface {
static function FromStreams(StreamIface $oSrce, StreamIface $oDest) : self;
}
class cUpdater extends BaseClass implements iUpdater {
// ++ SETUP ++ //
public static function FromStreams(StreamIface $oSrce, StreamIface $oDest) : iUpdater {
$oThis = new static;
$oThis->WithStreams($oSrce,$oDest);
return $oThis;
}
// ++ SETUP: dynamic ++ //
private $oSrce;
private $oDest;
protected function WithStreams(StreamIface $oSrce, StreamIface $oDest) {
$this->oSrce = $oSrce;
$this->oDest = $oDest;
}
// -- SETUP -- //
// ++ STATE ++ //
private $sSfx = NULL;
public function Suffix(?string $s) : string { return is_string($s) ? ($this->sSfx = $s) : $this->sSfx; }
// -- STATE -- //
// ++ EVENTS ++ //
// CEMENT
public function OnBefore() { // called before starting OnChange() / OnCheck() loop
$oPanel = CableAdmin::OPanel();
$oPanel->OnBefore();
}
// CEMENT
public function OnChange() { // called every time something changed
$oDest = $this->oDest;
$sDest = number_format($oDest->NPushedBytes());
$sMsg = $sDest.' bytes';
$oPanel = CableAdmin::OPanel();
$oPanel->Message($sMsg);
$oPanel->OnChange();
}
// CEMENT
public function OnCheck() { // less-frequent checks that may take longer to do
#$oPanel = CableAdmin::OPanel();
}
// CEMENT
public function OnAfter() { // called when there will be no more updates (so always update the display)
$oPanel = CableAdmin::OPanel();
$oPanel->OnAfter();
}
// -- EVENTS -- //
}