Remote / foldkit-remote/outbox

OutboxWiring

interface · packages/remote/src/outbox.ts:75

interface OutboxWiring<AppModel> extends Wiring<
  AppModel,
  RemoteMessage,
  KeyValueStore.KeyValueStore | RemoteClient
> {
  readonly restore: (
    model: AppModel,
  ) => Effect.Effect<AppModel, never, KeyValueStore.KeyValueStore>
  readonly session: (model: AppModel) => Effect.Effect<AppModel>
}

outbox's wiring, and the restore its runtime's init starts from.

Members

OutboxWiring.restore

property · packages/remote/src/outbox.ts:86

readonly restore: (
  model: AppModel,
) => Effect.Effect<AppModel, never, KeyValueStore.KeyValueStore>

The Model with the stored queue under its key read back, as the wiring would read it, and this page's session minted. Resolve it as the runtime's flags and start init from it: a durable write needs the session, and the first frame then shows the waiting writes.

OutboxWiring.session

property · packages/remote/src/outbox.ts:94

readonly session: (model: AppModel) => Effect.Effect<AppModel>

The Model with this page's session minted, and nothing read: what a page resumed from a server render starts from (SSR.hydrate's prepare), since the server cannot read the store and the first client view must be the served page. A durable write can then be made at once; the stored queue arrives after the first frame, as an OutboxRead, and keeps it.