Skip to content

Documentation / @etherfold/browser / ProgressReadable

Type Alias: ProgressReadable ​

ProgressReadable = Readable<HostProgress | undefined> & object

Defined in: packages/browser/src/host/progress.ts:37

THE SMALL HELPER FOR THE COMMON CASE: the pushed signal, as something a framework can bind to.

ADR-0082 decides that status is PUSHED and that an app builds whatever reactive wrapper its framework wants from that signal. This is that wrapper for the app that just wants a progress bar and should not be obliged to write one: the same Readable shape createIndexerState publishes its stores as (sveltore, which use-stores bridges to React), holding whatever the host last said.

svelte
const progress = createProgressReadable(indexer);
...
{#if $progress}
  {$progress.phase === 'at-tip' ? 'live' : `syncing, ${$progress.blocksBehindTip} blocks behind`}
{/if}

It is a VIEW, and never a second source of truth ​

What it holds is the host's own last report, kept by reference and replaced wholesale. It derives nothing, merges nothing into what it already had, and invents nothing while it is waiting: it is undefined until the host has answered, because "we have not been told yet" is a real state and a synthetic zero would render as a fold that has finished.

That is what keeps the helper OPTIONAL rather than load-bearing. An app with its own store, its own signal library or its own framework subscribes to port.onProgress directly and loses nothing, which is the property that makes this a convenience: there is exactly one place progress is decided, and it is the host.

Type Declaration ​

$state ​

readonly $state: HostProgress | undefined

The host's last report, or undefined before it has answered. The same convention createIndexerState's stores use for reading without subscribing.

close() ​

close(): void

Stop following. The port's subscription is released, so a host with nothing else listening stops posting.

Returns ​

void