Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

AddEventListener

addEventListener() is a common BrightSign method that is used to listen for an event.

...

Code Block
languagejs
target.addEventListener(type, listener);
  • [type string] type: Specifies  Specifies the type of event to listen for

  • [listener function] listener: The object to be notified when the event (of the specified type) happens 

RemoveEventListener

...

Code Block
languagejs
target.removeEventListener(type, listener);
  • [type string] type: Specifies the type of event to listen for

  • [listener function] listener: The   The object to be notified when the event (of the specified type) happens 

Example

Code Block
languagejs
function GPIOcontrolDown(msg){

    console.log(JSON.stringify(msg)); 
    console.log(" GPIO : " + msg.detail)
}

// to add an event listener for the "controldown" GPIO event

control_port.addEventListener("controldown", GPIOcontrolDown);

// to remove the "controldown" GPIO event listener

control_port.removeEventListener("controldown", GPIOcontrolDown);

...