Skip to content
Liminal

Snapshot and Delta Events

Client state depends on a deliberate snapshot-and-delta pattern:

  1. hydrate returns the initial state during audition.
  2. Later handlers emit delta events such as MoveMade or GameEnded.
  3. Client reducers fold deltas into the hydrated state.

Without hydration, a reconnecting UI usually needs a separate imperative fetch path.

Hydrate on connect

export const  = .(function* () {
  const  = yield* 
 
  return {
    : .,
    : .,
    : .,
  }
})

Delta from handlers

export const  = (
  ...,
  .(function* ({  }) {
    const  = yield* ()
 
    yield* ..("MessageAdded", {
      ,
    })
  }),
)

Reduce locally

export const  = .(
  "MessageAdded",
  ({  }) =>
    () =>
      .({
        ...,
        : [...., ],
      }),
)

This keeps the client state model hydrated before the UI sees it and event-driven afterward.

Read Lifecycle for hydrate and Client State for the reduction loop.