Skip to content
This repository was archived by the owner on May 23, 2026. It is now read-only.
This repository was archived by the owner on May 23, 2026. It is now read-only.

Migrate examples to selective persistence (lvt:"persist" tag) #43

Description

@adnaan

Context

The livetemplate library is replacing always-on state persistence with selective persistence via the lvt:"persist" struct tag. This is a breaking change that requires updates to examples.

Library PR: livetemplate/livetemplate (branch: selective-persist)

What changed in the library

  • WithEphemeralState()removed
  • lvt:"transient"removed
  • New: fields tagged lvt:"persist" are serialized to SessionStore and survive page refresh
  • Fields without the tag are ephemeral (zero value on reload, loaded by Mount())
  • No persist tags = fully ephemeral (equivalent to old WithEphemeralState())

Tasks

Delete redundant examples

  • Delete ephemeral-counter/ — redundant; no persist tags = ephemeral by default
  • Delete ephemeral-todos/ — redundant; regular todos/ now demonstrates the pattern

Add lvt:"persist" tags to examples with UI state

  • todos/ (state.go) — tag SearchQuery, SortBy, CurrentPage, PageSize with lvt:"persist"
  • todos-progressive/ — tag ActiveFilter with lvt:"persist"
  • chat/ — tag CurrentUser with lvt:"persist"

Update support files

  • test-all.sh — remove ephemeral-counter and ephemeral-todos entries (lines 39-40)
  • README.md — remove ephemeral-counter/ and ephemeral-todos/ rows; note which examples use lvt:"persist"
  • go.mod / go.sum — update livetemplate dependency to the version with this change

Examples that need no changes (correctly ephemeral)

counter, flash-messages, live-preview, login, profile-progressive, progressive-enhancement, shared-notepad, todos-components, ws-disabled, avatar-upload

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions