# Function: onAttributeUpdate
▸ onAttributeUpdate(handler
: AttributeUpdateEventHandler): void
开始监听属性更新事件
example
import { attributeSystem } from '@timi/mogs-sdk';
// ...
attributeSystem.onAttributeUpdate((ev) => {
console.log(ev.previousValue, ev.currentValue);
});
1
2
3
4
5
2
3
4
5
# 参数:
属性 | 类型 | 描述 |
---|---|---|
handler | AttributeUpdateEventHandler | 要注册的 Event Handler,可同时注册多个事件处理函数; |
AttributeUpdateEventHandler: MogsEventHandler‹AttributeUpdateEvent›
AttributeUpdateEvent
结构
属性 | 类型 | 描述 |
---|---|---|
attributeId | number | (发生变更的)属性 ID |
currentValue | ReadonlyClone‹Attribute | undefined› | 数据改变后的值 |
previousValue | ReadonlyClone‹Attribute | undefined› | 数据改变前的值 |
type | AttributeUpdateEventType | 事件类型,由具体的事件构造时提供 |
# 返回值:
void