Skip to content

Documentation / @etherfold/browser / demoteToReader

Function: demoteToReader() ​

demoteToReader(writer, reason): Demotion

Defined in: packages/browser/src/demotion.ts:143

DEMOTE A WRITER TO A READER: stop, forget, narrow, and SAY SO.

ts
// the refusal handler, and a lease holder, call the same function
demoteToReader(writer, 'write-refused');
demoteToReader(writer, 'lease-lost');

The warning is issued HERE rather than left to the caller, because the failure this whole path exists to remove is the QUIET one: an app following the documented createState example would otherwise get a tab that stops indexing for ever with nothing said anywhere. The caller publishes the returned Demotion on the surface an app already subscribes to; the log is what a developer finds when they wonder why the numbers stopped moving.

It does not throw, it is idempotent from the caller's side (demoting a writer that has already stopped costs three no-ops), and it never RE-CLAIMS: see the module note above for why becoming a writer again is a new store rather than a flag.

Parameters ​

writer ​

DemotableWriter

reason ​

DemotionReason

Returns ​

Demotion