Ferreteria/v0.6/clade/IO/Aspect/Connx/Stream/aux/Updater

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | IO‎ | Aspect‎ | Connx‎ | Stream
Jump to navigation Jump to search
clade: IO\Aspect\Connx\Stream\aux\Updater
Clade Family
Updater Updater (none)
Clade Aliases
Alias Clade
AppAdmin \App
Base* Sys\Events\Updater
PanelIface IO\O\Panel
StreamIface IO\Aspect\Connx\Stream
Subpages

About

  • Purpose: Sys\Events\Updater for Stream objects to use
    • It has a class-specific QObj-workalike: IO\Aspect\Connx\Stream\aux\Q\Updater

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
  • 2026-03-08 (I think) reorganized -- now takes a single Stream, not a pair; also goes directly to Panel, rather than going through Cable class

Code

as of 2026-03-24:

interface iUpdater extends BaseIface {}
class cUpdater extends BaseClass implements iUpdater {

    // ++ SETUP ++ //

    public static function FromStream(StreamIface $o) : iUpdater {
        $oThis = new static;
        $oThis->WithStream($o);
        return $oThis;
    }

    // ++ SETUP: dynamic ++ //

    private $oStream;
    protected function WithStream(StreamIface $o) { $this->oStream = $o; }

    // -- 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 main loop
        $oPanel = $this->OPanel();
        $oPanel->OnBefore();
    }
    // CEMENT
    public function OnIterate() {  // called every time something changed
        $sMsg = $this->OStream()->DescribeInline();
        $oPanel = $this->OPanel();
        $oPanel->Message($sMsg);
        $oPanel->OnIterate();
    }
    // CEMENT
    public function OnAfter() {   // called when there will be no more updates (so always update the display)
        $oPanel = $this->OPanel();
        $oPanel->OnAfter();
    }

    // -- EVENTS -- //
    // ++ OBJECTS ++ //

    protected function OPanel() : PanelIface { return AppAdmin::Me()->OPanel(); }
    protected function OStream() : StreamIface { return $this->oStream; }

    // -- OBJECTS -- //
}