replace

package
v0.0.0-...-ef14c93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package replace demonstrates screen.Replace — atomic top-of-stack swap.

Two screens, each with mutable state the user can see change:

cityList: a filterable list of cities. The filter and cursor are state.
          Press r → Replace with a fresh cityList. Filter clears, cursor
          jumps to top, breadcrumb depth stays at 1 (no flicker).

cityDetail: pushed via enter on the list. Holds a visit counter that
            bumps on `+`. Press r → Replace with a fresh cityDetail for
            the same city. Counter resets to 0; the cityList beneath
            stays put — its OnEnter does NOT fire (which is the whole
            point: pop+push would fire it on the parent).

Compare against pop+push, which would (a) flicker visibly between frames and (b) call OnEnter on the parent that briefly becomes the top, often retriggering side effects (refetch, scroll-to-cursor, …).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t theme.Theme) screen.Screen

New returns the demo's root screen.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL