• Hi,

    I would like to create my own event handlers similar like the Bangle event handlers, f.i. the "step" handler.

    Bangle.on('step', function(up) {
      print("step was made");

    Tried this example from https://www.w3schools.com/nodejs/nodejs_­events.asp

    var events = require('events');
    var eventEmitter = new events.EventEmitter();
    //Create an event handler:
    var myEventHandler = function () {
      console.log('I hear a scream!');
    //Assign the event handler to an event:
    eventEmitter.on('scream', myEventHandler);
    //Fire the 'scream' event:

    But this results in the error:

    I read in the Espruino documentation here http://www.espruino.com/Reference#l_Obje­ct_emit about Object.emit and Object.on but can not find any reference or example on how to setup an eventEmitter in Espruino.

    I'm rather new to Espruino/Javascript so maybe there's an obvious answer. Can someone point me in the right direction?


Avatar for gerardwr @gerardwr started