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

Function UseTicker

tsunami/app/hooks.go:191–205  ·  view source on GitHub ↗

UseTicker manages a ticker lifecycle within a component. It creates a ticker that calls the provided function at regular intervals. The ticker is automatically stopped on dependency changes or component unmount. This hook must be called within a component context.

(interval time.Duration, tickFn func(), deps []any)

Source from the content-addressed store, hash-verified

189// The ticker is automatically stopped on dependency changes or component unmount.
190// This hook must be called within a component context.
191func UseTicker(interval time.Duration, tickFn func(), deps []any) {
192 UseGoRoutine(func(ctx context.Context) {
193 ticker := time.NewTicker(interval)
194 defer ticker.Stop()
195
196 for {
197 select {
198 case <-ctx.Done():
199 return
200 case <-ticker.C:
201 tickFn()
202 }
203 }
204 }, deps)
205}
206
207// UseAfter manages a timeout lifecycle within a component.
208// It creates a timer that calls the provided function after the specified duration.

Callers 4

app.goFile · 0.92
app.goFile · 0.92
app.goFile · 0.92
app.goFile · 0.92

Calls 2

UseGoRoutineFunction · 0.85
StopMethod · 0.65

Tested by

no test coverage detected