events.on

Section: Events

What it does

events.on acts on events: it listens. It takes name and a function, and answers unsubscribe fn.

Signature

events.on(name, (data) => {...}) → unsubscribe fn

Arguments

  • name
  • (data) => {...}

    Accepts:data

Example · generated

function start() {  const result = events.on('main', (data) => {});}

events.on 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.

3 members in events