inventory.onChange

Section: Inventory

What it does

inventory.onChange listens for Change on inventory: the function you hand it is called back each time. It takes cb, and answers unsubscribe.

Signature

inventory.onChange(cb) → unsubscribe

Arguments

  • cb

Example · generated

function start() {  const unsubscribe = inventory.onChange(() => {});}

inventory.onChange is called with values of the shape its signature asks for. The code sits in start(), which the engine calls once, when the entity spawns.

18 members in inventory