3
  1. If I include a managed Lightning component within an unmanaged container component can the two communicate? If yes will it be via events or by setting an attribute on either component?

    For example assume my package namespace is pkg and inside of it there is a component called pkg:accountSelector that allows users to select an Account from a dropdown. Inside a client org I want to create a local component and put pkg:accountSelector inside of it. When user selects an Account which of the following can happen?

    • An attribute in the container gets set to the selection
    • The container receives an event containing the selection (fired from pkg:accountSelector)

    In the end client-side Apex will want to use the selection and process it.

  2. If I use facets to define content for a managed component in an unmanaged client org can the two communicate?

    This is similar to my 1st question, but with a different scenario: assume pkg:application is my managed component. It's a generic application form with a Submit button and a facet called partC whose content depends on client. Inside a client org I want to define partC as a set of input fields and have their values sent up to the container (i.e. pkg:application). When user clicks Submit the container would gather up all the information from the application form, including inputs in Part C, and send them to Apex for processing. Again:

    • Does the unmanaged component set attributes on the managed container component? or
    • Does the unmanaged component publish an event to the container component?

1 Answer 1

0

If I include a managed Lightning component within an unmanaged container component can the two communicate?

Yes.

If yes will it be via events or by setting an attribute on either component?

Either, depending on the developer's intent. Note that with the introduction of LWC, it is preferred that the developer use events for communicating data changes up to the parent component, but this is not a strict requirement with Aura.

An attribute in the container gets set to the selection

Presuming the attribute is global, the subscriber's component can access the applicable attribute, and even listen for it via aura:valueChange events.

The container receives an event containing the selection (fired from pkg:accountSelector)

Presuming the event is global, the subscriber's component can listen for the applicable event and take appropriate action.

If I use facets to define content for a managed component in an unmanaged client org can the two communicate?

The managed component would need to be given a copy of the data. In theory, it would look like this:

<aura:attribute name="data" type="Map" access="global" />
<pkg:application data="{!v.data}">
  <lightning:input value="{!v.data.value1}" label="abc" />
  <lightning:input value="{!v.data.value2}" label="xyz" />
</pkg:application>

There doesn't need to be any exact communication, as Aura should handle it correctly for you. However, sometimes these types of data bindings don't work as expected, so additional events or code might be necessary to get this working correctly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .