# Function: onBackpackRefresh

onBackpackRefresh(handler: BackpackRefreshEventHandler): void

注册 背包(全量)刷新 事件处理函数

example

import { backpackSystem } from '@timi/mogs-sdk';

backpackSystem.onBackpackRefresh(async (event) => {
  const backpacks = await backpackSystem.backpacks;
  const backpack = backpacks[event.backpackId];
  for (let position = 0; position < backpack.maxCount; position += 1) {
    const item = backpack.items.get(position);
    if (item) {
      // 重新绘制位置为 position 的物品的 UI
    }
  }
});
1
2
3
4
5
6
7
8
9
10
11
12

# 参数:

属性 类型
handler BackpackRefreshEventHandler

# 返回值:

void