MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / UseLocal

Function UseLocal

tsunami/app/hooks.go:131–141  ·  view source on GitHub ↗

UseLocal creates a component-local atom that is automatically cleaned up when the component unmounts. The atom is created with a unique name based on the component's wave ID and hook index. This hook must be called within a component context.

(initialVal T)

Source from the content-addressed store, hash-verified

129// The atom is created with a unique name based on the component's wave ID and hook index.
130// This hook must be called within a component context.
131func UseLocal[T any](initialVal T) Atom[T] {
132 rc := engine.GetGlobalRenderContext()
133 if rc == nil {
134 panic("UseLocal must be called within a component (no context)")
135 }
136 atomName := engine.UseLocal(rc, initialVal)
137 return Atom[T]{
138 name: atomName,
139 client: engine.GetDefaultClient(),
140 }
141}
142
143// UseGoRoutine manages a goroutine lifecycle within a component.
144// It spawns a new goroutine with the provided function when dependencies change,

Callers 7

genTableRenderFuncFunction · 0.92
app.goFile · 0.92
app.goFile · 0.92
app.goFile · 0.92
app.goFile · 0.92
UseAlertModalFunction · 0.70
UseConfirmModalFunction · 0.70

Calls 3

GetGlobalRenderContextFunction · 0.92
UseLocalFunction · 0.92
GetDefaultClientFunction · 0.92

Tested by

no test coverage detected