Can a Promise be passed as an attribute of a Lightning Component application event?

I am attempting (but failing – getting undefined when the event is handled) to pass a Promise returned by a lightning:workspaceAPI getEnclosingTabId call as an attribute of an application event.

Do you expect this to work and its just a bug in my code?


The answer is yes a Promise can be passed in an event based on this code working:

accept : function(component, event, action) {
    var cId = component.get("v.instanceId");
    var eId = event.getParams().instanceId;
    if (cId && eId) {
        Promise.all([cId, eId]).then($A.getCallback(function(ids) {
            if (ids[0] === ids[1]) action();
        })).catch($A.getCallback(function(err) {
            console.error("ERROR: " + err);

This code is comparing an aura:attribute that is a Promise with an event attribute that is a promise.

Thanks to this important point Promise and access to access=private attributes I now have the $A.getCallback in there too.

Source : Link , Question Author : Keith C , Answer Author : Keith C

Leave a Comment