本文整理匯總了TypeScript中core/has_props.HasProps.ref方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript HasProps.ref方法的具體用法?TypeScript HasProps.ref怎麽用?TypeScript HasProps.ref使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類core/has_props.HasProps
的用法示例。
在下文中一共展示了HasProps.ref方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: json
json(references: References): DocumentChanged {
if (this.attr === "id") {
throw new Error("'id' field should never change, whatever code just set it is wrong")
}
if (this.hint != null)
return this.hint.json(references)
const value = this.new_
const value_json = HasProps._value_to_json(this.attr, value, this.model)
const value_refs: {[key: string]: any} = {}
HasProps._value_record_references(value, value_refs, true) // true = recurse
if (this.model.id in value_refs && this.model !== value) {
// we know we don't want a whole new copy of the obj we're
// patching unless it's also the value itself
delete value_refs[this.model.id]
}
for (const id in value_refs) {
references[id] = value_refs[id]
}
return {
kind: "ModelChanged",
model: this.model.ref(),
attr: this.attr,
new: value_json,
}
}