block 指令块
block
类型: MethodDeclaration
所属类: CommandFunctionList
定义位置: command.ts
描述
指令块
参数
参数名 | 类型 | 描述 | 默认值 |
---|---|---|---|
\{note, asynchronous, commands\} | `{ | ||
note: string, | |||
asynchronous: boolean, | |||
commands: CommandDataList, | |||
}` | - | - |
返回值
类型: CommandFunction \| CommandFunctionList
源代码
位置: 第 4052 行
protected block({note, asynchronous, commands}: {
note: string,
asynchronous: boolean,
commands: CommandDataList,
}): CommandFunction | CommandFunctionList {
// 补丁:2025-3-21
if (asynchronous === undefined) {
asynchronous = false
}
switch (asynchronous) {
case false: {
const functions = Command.compile(commands)
functions.remove(Command.readStack)
return functions
}
case true: {
const commandList = Command.compileIndependent(commands)
commandList.type = 'asynchronous'
return () => {
const copy = Object.create(commandList) as CommandFunctionList
copy.inheritance = CurrentEvent
const mainEvent = CurrentEvent as any
if (mainEvent[Command.asyncKey] === undefined) {
mainEvent[Command.asyncKey] = []
CurrentEvent.onFinish(() => {
let i = asyncEvents.length
while (--i >= 0) {
asyncEvents[i].finish()
}
})
}
const asyncEvents = mainEvent[Command.asyncKey] as Array<EventHandler>
const asyncEvent = new EventHandler(copy)
EventHandler.call(asyncEvent, CurrentEvent.updaters)
if (!asyncEvent.complete) {
asyncEvents.push(asyncEvent)
asyncEvent.onFinish(() => {
asyncEvents.remove(asyncEvent)
})
}
return true
}
}
}
}
文档生成时间:2025/7/7 12:07:06