MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / setValue

Method setValue

packages/designer/src/document/node/props/prop.ts:354–390  ·  view source on GitHub ↗
(val: IPublicTypeCompositeValue)

Source from the content-addressed store, hash-verified

352 */
353 @action
354 setValue(val: IPublicTypeCompositeValue) {
355 if (val === this._value) return;
356 const oldValue = this._value;
357 this._value = val;
358 this._code = null;
359 const t = typeof val;
360 if (val == null) {
361 // this._value = undefined;
362 this._type = 'literal';
363 } else if (t === 'string' || t === 'number' || t === 'boolean') {
364 this._type = 'literal';
365 } else if (Array.isArray(val)) {
366 this._type = 'list';
367 } else if (isPlainObject(val)) {
368 if (isJSSlot(val)) {
369 this.setAsSlot(val);
370 } else if (isJSExpression(val)) {
371 this._type = 'expression';
372 } else {
373 this._type = 'map';
374 }
375 } else /* istanbul ignore next */ {
376 this._type = 'expression';
377 this._value = {
378 type: 'JSExpression',
379 value: valueToSource(val),
380 };
381 }
382
383 this.dispose();
384 // setValue 的时候,如果不重新建立 items,items 的 setValue 没有触发,会导致子项的响应式逻辑不能被触发
385 this.setupItems();
386
387 if (oldValue !== this._value) {
388 this.emitChange({ oldValue });
389 }
390 }
391
392 emitChange = ({
393 oldValue,

Callers 4

codeMethod · 0.95
constructorMethod · 0.95
addMethod · 0.95
setMethod · 0.95

Calls 7

setAsSlotMethod · 0.95
disposeMethod · 0.95
setupItemsMethod · 0.95
valueToSourceFunction · 0.90
isPlainObjectFunction · 0.50
isJSSlotFunction · 0.50
isJSExpressionFunction · 0.50

Tested by

no test coverage detected