本文整理汇总了TypeScript中mithril.startComputation函数的典型用法代码示例。如果您正苦于以下问题:TypeScript startComputation函数的具体用法?TypeScript startComputation怎么用?TypeScript startComputation使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了startComputation函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: return
return (errorCode) => {
if (errorCode) {
m.startComputation()
_errorCode = errorCode
m.endComputation()
}
return _errorCode || ErrorCodes.NONE
}
示例2: radio
let search = (treeViewInstance, value) => {
m.startComputation()
let searchTerm = value.toLowerCase()
if (willChange) {
radio(PubSubTopics.TREE_STRUCTURE_CHANGED).unsubscribe(updateAllNodes)
clearTimeout(willChange)
m.endComputation()
}
let context = { treeViewInstance: treeViewInstance, searchTerm: searchTerm }
willChange = setTimeout(updateAllNodes.bind(context), 300)
// retrigger the search every time the tree structure changes (this happens when nodes are created/deleted)
radio(PubSubTopics.TREE_STRUCTURE_CHANGED).subscribe([updateAllNodes, context])
}
示例3: selectedAccessor
return function selectedAccessor(selected) {
if (selected !== void 0) {
cachedSelected = selected
m.startComputation()
if (selected) {
// deselect all previously selected nodes
root.selectedNodes().map((node) => {
node.selected(false)
})
// override all previously cached selected nodes with the currently selected one
root.selectedNodes([this])
} else {
root.selectedNodes(root.selectedNodes().filter((node) => {
return node.id() !== this.id()
}))
}
m.endComputation()
}
return cachedSelected
}
示例4: Promise
return new Promise((resolve, reject) => {
if (!childData) {
reject('[createChild] Tree node creation failed: No data given! Please check your options.childData object.')
} else if (!childData.id) {
reject('[createChild] Tree node creation failed: No id given! Please ensure options.childData.id is filled with a "valid" id string.' +
' "Valid" id strings are based on HTML element ids.')
} else if (!childData.title) {
reject('[createChild] Tree node creation failed: No title given! Please ensure options.childData.title is filled with a string.')
} else {
childData.root = root
childData.parent = nodeData
childData.events = nodeData.events
if (nodeData.errorCode() === ErrorCodes.NOT_FOUND) {
nodeData.errorCode(ErrorCodes.NONE)
}
let newTreeNode = createNodeData(childData)
let newChildList = nodeData.children()
newChildList.push(newTreeNode)
nodeData.children(newChildList)
m.startComputation()
resolve(newTreeNode)
m.endComputation()
}
})
示例5:
fs.readFile(storedFileName, "utf-8", (err: any, data: any) => {
m.startComputation();
context.loadData(data);
m.endComputation();
});