跳到主要内容

setState 设置状态

setState

类型: MethodDeclaration

所属类: CommandFunctionList

定义位置: command.ts

描述

设置状态

参数

参数名类型描述默认值
\{state, operation, time\}`{
state: StateGetter
operation: string
time: number | VariableGetter
}`--

返回值

类型: CommandFunction

源代码

位置: 第 5229 行

protected setState({state, operation, time}: {
state: StateGetter
operation: string
time: number | VariableGetter
}): CommandFunction {
const getState = Command.compileState(state)
const getTime = Command.compileNumber(time)
switch (operation) {
case 'set-time':
return () => {
getState()?.setTime(getTime())
return true
}
case 'increase-time':
return () => {
getState()?.increaseTime(getTime())
return true
}
case 'decrease-time':
return () => {
getState()?.decreaseTime(getTime())
return true
}
}
throw new Error('Compiling Error')
}

文档生成时间:2025/7/7 12:07:06