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, and a program not run by `jamb dev` keeps nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Checkpoint ¶
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 ¶
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.