Browse Source

Refactor with ObjectAny

pull/6351/head
mohamedsalem401 1 year ago
parent
commit
948aeac297
  1. 7
      packages/core/src/dom_components/model/ComponentDynamicValueListener.ts
  2. 7
      packages/core/src/dom_components/model/DynamicValueWatcher.ts

7
packages/core/src/dom_components/model/ComponentDynamicValueListener.ts

@ -1,5 +1,4 @@
import { ObjectAny } from '../../common';
import { evaluateDynamicValueDefinition, isDynamicValueDefinition } from '../../data_sources/model/utils';
import EditorModel from '../../editor/model/Editor';
import Component from './Component';
import { DynamicValueWatcher } from './DynamicValueWatcher';
@ -22,9 +21,7 @@ export class ComponentDynamicValueListener {
}
static evaluateComponentDef(
values: {
[key: string]: any;
},
values: ObjectAny,
em: EditorModel,
) {
const props = DynamicValueWatcher.getStaticValues(values, em);
@ -33,7 +30,7 @@ export class ComponentDynamicValueListener {
return props;
}
watchComponentDef(values: { [key: string]: any }) {
watchComponentDef(values: ObjectAny) {
this.watchProps(values);
this.watchAttributes(values.attributes);
}

7
packages/core/src/dom_components/model/DynamicValueWatcher.ts

@ -1,3 +1,4 @@
import { ObjectAny } from '../../common';
import DynamicVariableListenerManager from '../../data_sources/model/DataVariableListenerManager';
import { evaluateDynamicValueDefinition, isDynamicValueDefinition } from '../../data_sources/model/utils';
import EditorModel from '../../editor/model/Editor';
@ -27,13 +28,13 @@ export class DynamicValueWatcher {
return evaluatedValues;
}
static areStaticValues(values: { [key: string]: any }) {
static areStaticValues(values: ObjectAny) {
return Object.keys(values).every((key) => {
return !isDynamicValueDefinition(values[key]);
});
}
watchDynamicValue(values: { [key: string]: any }) {
watchDynamicValue(values: ObjectAny) {
const dynamicProps = this.getDynamicValues(values);
const propsKeys = Object.keys(dynamicProps);
for (let index = 0; index < propsKeys.length; index++) {
@ -51,7 +52,7 @@ export class DynamicValueWatcher {
return dynamicProps;
}
private getDynamicValues(values: { [key: string]: any }) {
private getDynamicValues(values: ObjectAny) {
const dynamicValues = { ...values };
const propsKeys = Object.keys(dynamicValues);
for (let index = 0; index < propsKeys.length; index++) {

Loading…
Cancel
Save