Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.04 KB

how_does_it_work.md

File metadata and controls

39 lines (27 loc) · 1.04 KB

⬅️ to README.md

How does it work?

WIP

  • Basically, on every iteration sequence is written to output stream(stderr by default) and cursor is moved back by sequence width to its original position.

Driver

The Driver is the central element of the system, responsible for rendering the current frame and sending it to the output through its render() method. If no spinner is registered with the driver, nothing will be rendered and sent to the output.

$spinnerSettings = new SpinnerSettings(autoAttach: false);

$spinner = Facade::createSpinner($spinnerSettings);

$driver = Facade::getDriver();

$driver->add($spinner);

If an event-loop is available, the driver will be linked to the loop using IDriverLinker implementation. Thus, render() method will be called automatically.

$this->loop->repeat(
    $driver->getInterval()->toSeconds(),
    static fn() => $driver->render()
);

If no loop is available, the render() method must be called manually.

$driver->render();