Do you know how to make aura component handle an event captured from External javascript api?

The process likes below:
1. A javascript api is in the static resource.
2. Aura component contains the script.
3. An event occurs and is handled by JS.
4. JS notices the event to aura component.
5. Aura component handles the event.

I tried running the guide presented on developer.salesforce.com, but it says "window.$A.get("e.mynamespace:externalEvent") is undefined."(https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_external.htm)

var myExternalEvent;
if(window.$A &&
  (myExternalEvent = window.$A.get("e.mynamespace:externalEvent"))) {

If the above code is the right way, and I don't understand that code, can you explain it with an example?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.