hot

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hot keeps an app's state across the restarts of `jamb dev`: every signal the app makes with ui.NewSignal, and every ui.Local, has the value it had before the restart, with no code in the app. See docs/tools.md, "State across restarts".

`jamb dev` rewrites, in copies it builds from, each ui.NewSignal call of the app's own module into a call of Signal, with a key named after the source: the package's directory, the function, and the variable or field the signal is assigned to. Before it stops the app, it asks for a checkpoint over the control channel, and it starts the new build with JAMB_STATE_FILE naming it. Each signal then takes its old value as it is made, and each local as its component first renders. Code that sets a signal after making it, such as startup code loading a file, sets it after that, as a React effect runs after its state is restored.

A value whose type changed so that the old one does not fit, and one that cannot be kept (it holds a func or a channel), starts from its initial value, and the app says which. Nothing of this package is in a program that does not link package devtools, or in a web build, which `jamb dev` does not run. A program that `jamb dev` did not start keeps nothing and does no work for it: keeping a value means encoding it when it is made (see entry.Base), which for a local that holds a large table takes longer than the frame it is made in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Checkpoint

func Checkpoint(path string) (int, error)

Checkpoint writes the values of the signals and locals alive now to the file at path, and returns how many it wrote. Call it on the UI thread, so that no render is half done. Values that cannot be kept are left out and named on standard error.

func Component

func Component(c *ui.ComponentElement, site string) *ui.ComponentElement

Component is what `jamb dev` makes of each ui.Component call: it names the component by its call in the source, site, so that its locals are found again after a restart even when components around it moved (see ui's sitePath).

func Signal

func Signal[T any](s *ui.Signal[T], key string) *ui.Signal[T]

Signal is what `jamb dev` makes of each ui.NewSignal call: it gives s the value that the signal with the same key had before the restart, and keeps track of s for the next one. key names the call in the source; the signals made by one call are told apart by the order they are made in.

A signal made while the app starts, by package variables or code before app.Run, gets its value when the app has started, after any code that sets it at startup (see restore). One made later gets it at once.

Types

This section is empty.

Jump to

Keyboard shortcuts

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