Home > PCB_Event > addRealTimeDrcResultEventListener
PCB_Event.addRealTimeDrcResultEventListener() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
新增实时 DRC 结果事件监听
签名
typescript
function addRealTimeDrcResultEventListener(
id: string,
eventType: 'all',
callFn: (eventType: undefined, props: [{ drcResult: any }]) => void | Promise<void>,
): void;1
2
3
4
5
2
3
4
5
参数名
参数 | 类型 | 描述 |
|---|---|---|
id | string | 事件 ID,用以防止重复注册事件 |
eventType | 'all' | 事件类型 |
callFn | (eventType: undefined, props: [{ drcResult: any }]) => void | Promise<void> | 事件触发时的回调函数 |
返回值
void
备注
注意:本接口仅扩展有效,在独立脚本环境内调用将始终 throw Error
示例
javascript
const listenerId = '嘉立创示例_drc_result';
// 1. 注册实时 DRC 结果监听,eventType 固定为 'all'
eda.pcb_Event.addRealTimeDrcResultEventListener(
listenerId,
'all',
(eventType, props) => {
// 回调在实时 DRC 检出违规时触发;props 是 DRC 结果数组
console.log('drcResult:', JSON.stringify(props));
}
);
// 2. 回读确认注册成功
const registered = eda.pcb_Event.isEventListenerAlreadyExist(listenerId);
console.log('registered:', registered);
// 3. 清理监听
const removed = eda.pcb_Event.removeEventListener(listenerId);
console.log('removed:', removed);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19