MCPcopy Create free account
hub / github.com/chieapp/chie / constructor

Method constructor

src/view/params-view.ts:101–127  ·  view source on GitHub ↗
(param: Param, constrainedBy?: ParamRow, nullable = false)

Source from the content-addressed store, hash-verified

99 constrainedBy?: ParamRow;
100
101 constructor(param: Param, constrainedBy?: ParamRow, nullable = false) {
102 if (!param.selections)
103 throw new Error('Property "selections" expected.');
104 super(param, gui.Picker.create(), nullable);
105
106 this.selections = param.selections instanceof Function ? param.selections() : param.selections;
107
108 // Listen to controlling param's change and update.
109 if (constrainedBy) {
110 this.constrainedBy = constrainedBy;
111 constrainedBy.affects.push(this);
112 constrainedBy.subscribeOnChange(() => {
113 this.update();
114 // Iterate all params constrained by this.
115 this.affects.forEach(p => p.update());
116 });
117 }
118 // There is a description field in selection.
119 if (this.selections.length > 0 &&
120 typeof this.selections[0].value == 'object' &&
121 'description' in this.selections[0].value) {
122 this.createDescription();
123 this.subscribeOnChange(() => this.#updateDescription());
124 }
125 // Fill the picker with selections.
126 this.update();
127 }
128
129 update() {
130 let selections = this.selections;

Callers

nothing calls this directly

Calls 4

updateMethod · 0.95
subscribeOnChangeMethod · 0.95
#updateDescriptionMethod · 0.95
subscribeOnChangeMethod · 0.45

Tested by

no test coverage detected