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

Function UseVDomRef

pkg/vdom/vdom.go:385–397  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

383}
384
385func UseVDomRef(ctx context.Context) *VDomRef {
386 vc, hookVal := getHookFromCtx(ctx)
387 if !hookVal.Init {
388 hookVal.Init = true
389 refId := vc.Comp.WaveId + ":" + strconv.Itoa(hookVal.Idx)
390 hookVal.Val = &VDomRef{Type: ObjectType_Ref, RefId: refId}
391 }
392 refVal, ok := hookVal.Val.(*VDomRef)
393 if !ok {
394 panic("UseRef hook value is not a ref (possible out of order or conditional hooks)")
395 }
396 return refVal
397}
398
399func UseRef[T any](ctx context.Context, val T) *VDomSimpleRef[T] {
400 _, hookVal := getHookFromCtx(ctx)

Callers 1

ButtonFunction · 0.70

Calls 1

getHookFromCtxFunction · 0.85

Tested by 1

ButtonFunction · 0.56