MCPcopy
hub / github.com/cockpit-project/cockpit / sub

Method sub

pkg/lib/cockpit/dialog.tsx:761–776  ·  view source on GitHub ↗
(tag: K, update_func?: ((val: T[K]) => void) | undefined)

Source from the content-addressed store, hash-verified

759 }
760
761 sub<K extends keyof T>(tag: K, update_func?: ((val: T[K]) => void) | undefined): DialogField<T[K]> {
762 return new DialogField<T[K]>(
763 this.#dialog,
764 () => this.get()[tag],
765 (val) => {
766 const container = this.get();
767 if (Array.isArray(container) && typeof tag == "number")
768 this.#setter(toSpliced(container, tag, 1, val) as T);
769 else
770 this.#setter({ ...container, [tag]: val });
771 if (update_func)
772 update_func(val);
773 },
774 this.#path ? this.#path + "." + String(tag) : String(tag)
775 );
776 }
777
778 at<TT extends T>(witness: TT): DialogField<TT> {
779 cockpit.assert(Object.is(witness, this.get()));

Callers 9

mapMethod · 0.95
forEachMethod · 0.95
fieldMethod · 0.80
NameInputFunction · 0.80
validate_NameFunction · 0.80
AsyncExampleDialogFunction · 0.80
field_unescapeFunction · 0.80
test_browserFunction · 0.80
ensure_scannedMethod · 0.80

Calls 2

getMethod · 0.95
toSplicedFunction · 0.85

Tested by 1

test_browserFunction · 0.64