close method

Future<void> close()

Closes the instance. Idempotent: a second call returns the same Future.

Every open stream ends with done and no error event (a close is not a failure): the events still queued for it are dropped inside this call, and done comes in a microtask (after resume for a paused subscription, following its buffered events). Every pending Future (writes, gets, once, transactions, onDisconnect operations) fails with database-closed, then the returned Future completes. Writes that were not acknowledged fail here; with persistence they stay on disk and the next instance sends them. Closing ends the connection, so the server applies the onDisconnect writes this client registered. Afterwards every asynchronous call fails with database-closed, a stream listened to ends with done and no error, ref still works (it makes no request), and goOnline and goOffline do nothing.

Implementation

Future<void> close() => _closeFuture ??= _close();