本文整理汇总了TypeScript中eez-studio-shared/model/store.DocumentStore.updateObject方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DocumentStore.updateObject方法的具体用法?TypeScript DocumentStore.updateObject怎么用?TypeScript DocumentStore.updateObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eez-studio-shared/model/store.DocumentStore
的用法示例。
在下文中一共展示了DocumentStore.updateObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: unsetResolutionDependablePropertyForCurrentResolution
export function unsetResolutionDependablePropertyForCurrentResolution(
object: EezObject,
propertyName: string
) {
const allValues: (any | null)[] = getPropertyValueForAllResolutions(object, propertyName);
allValues[getPageContext().resolution] = null;
while (allValues.length > 1 && allValues[allValues.length - 1] === null) {
allValues.pop();
}
DocumentStore.updateObject(object, {
[propertyName + "_"]: allValues
});
}
示例2: resetInObject
function resetInObject(object: EezObject) {
const changes: {
[key: string]: any;
} = {};
object._classInfo.properties.forEach(propertyInfo => {
if (propertyInfo.resolutionDependable) {
const value = getPropertyValueForAllResolutions(object, propertyInfo.name);
for (let i = getPageContext().resolution + 1; i < value.length; i++) {
value[i] = null;
}
changes[propertyInfo.name + "_"] = value;
}
});
DocumentStore.updateObject(object, changes);
getChildren(object).forEach(resetInObject);
}
示例3: replaceObjectReference
export function replaceObjectReference(object: EezObject, newValue: string) {
let resultsGenerator = searchForReference(DocumentStore.document, object, false);
while (true) {
let searchResult = resultsGenerator.next();
if (searchResult.done) {
break;
}
let searchValue = searchResult.value;
if (searchValue) {
let value: string | string[] = newValue;
if (searchValue.propertyInfo.replaceObjectReference) {
value = searchValue.propertyInfo.replaceObjectReference(value);
} else if (searchValue.propertyInfo.type === PropertyType.ConfigurationReference) {
value = [];
for (let i = 0; i < searchValue.value.length; i++) {
if (searchValue.value[i] !== getProperty(object, "name")) {
value.push(searchValue.value[i]);
} else {
value.push(newValue);
}
}
}
let parent = searchValue._parent;
if (parent) {
let key = searchValue._key;
if (parent && key && typeof key == "string") {
DocumentStore.updateObject(parent, {
[key]: value
});
}
}
}
}
}