call definition of $A.enqueueAction(action);

fn: function(cmp, event, helper)
    {
        var action=cmp.get("c.apexMethod");
         action.setParams({ "param1" : 'value1'});
       
         action.setCallback(this, function(response) {
            var state = response.getState();
             if (state === "SUCCESS")
            {
                var result=response.getReturnValue();
                 if(!$A.util.isUndefinedOrNull(result) && !$A.util.inEmpty(result))
                  {
                       //some code here
                   }
            }
            if (state === "NEW")
            {
                console.log("The action was created but is not in progress yet");
            }
           else if (state === "RUNNING")
            {
                console.log("The action is in progress");
               
            }
             else if (state === "ERROR")
            {
                console.log("The action is in progress");
               
            }
             else if (state === "INCOMPLETE")
            {
                console.log("The server didn't return a response. The server might be down or the client might be offline. The framework guarantees that an action's callback is always invoked as long as the component is valid. If the socket to the server is never successfully opened, or closes abruptly, or any other network error occurs, the XHR resolves and the callback is invoked with state equal to INCOMPLETE.");
               
            }
              else if (state === "ABORTED")
            {
                console.log("The action was aborted. This action state is deprecated. A callback for an aborted action is never executed so you can’t do anything to handle this state.");
               
            }
         });
       $A.enqueueAction(action);
      }

How to get all component's attributes value by one call of component.get();

In This article,I explained how to set all component's attributes value by one call.
In the similar way we can get all the componets values by one call of componet.get()

<!--- Lightning Component  ---->
<aura:component>
<aura:attribute name="map" type="Map" default="{str1:null,str2:null,obj:null}"/>
<aura:attribute name="str1" type="String"  default="{!v.map.str1}"/>
 <aura:attribute name="str2" type="String" default="{!v.map.str2}"/>
 <aura:attribute name="obj" type="Contact" default="{!v.map.obj}"/>
</aura:component>




------------Lightning Component Controller--------------------------
fn: function(cmp, event, helper)
    {
        var map=cmp.get("v.map");//top or START of function
           console.log(map.str1);
           console.log(map.str2);
       
}

How to set all component's attributes value by one call of component.set();

<!--- Lightning Component  ---->
<aura:component>
<aura:attribute name="map" type="Map" default="{str1:null,str2:null,obj:null}"/>
<aura:attribute name="str1" type="String"  default="{!v.map.str1}"/>
 <aura:attribute name="str2" type="String" default="{!v.map.str2}"/>
 <aura:attribute name="obj" type="Contact" default="{!v.map.obj}"/>
</aura:component>




------------Lightning Component Controller--------------------------
fn: function(cmp, event, helper)
    {
        var map=cmp.get("v.map");//top or START of function
           //some logic here
        map['str1']='LastName';
         //some logic here
        map['str2']='Firstname';
        //some logic here
        var obj={"FirstName":"Ram","LastName":'Lakhan'};
        map['obj']=obj;

        cmp.set("v.map",map);// END of function
}

Setting Label Values via a Parent Attribute



Setting label values via a parent attribute is useful if you want control over labels in child components.
Let’s say that you have a container component, which contains another component, inner.cmp. You want to set a label value in inner.cmp via an attribute on the container component. This can be done by specifying the attribute type and default value. You must set a default value in the parent attribute if you are setting a label on an inner component, as shown in the following example.
This is the container component, which contains a default value My Label for the _label attribute .
1<aura:component>
2    <aura:attribute name="_label"
3                    type="String"
4                    default="My Label"/>
5    <lightning:button label="Set Label" aura:id="button1" onclick="{!c.setLabel}"/>
6    <auradocs:inner aura:id="inner" label="{!v._label}"/>
7</aura:component>
This inner component contains a text area component and a label attribute that’s set by the container component.
1<aura:component>
2    <aura:attribute name="label" type="String"/>
3    <lightning:textarea aura:id="textarea"
4                      name="myTextarea"
5                      label="{!v.label}"/>
6</aura:component>
This client-side controller action updates the label value.
1({
2    setLabel:function(cmp) {
3        cmp.set("v._label", 'new label');
4    }
5})
When the component is initialized, you’ll see a button and a text area with the label My Label. When the button in the container component is clicked, the setLabel action updates the label value in the inner component. This action finds the label attribute and sets its value to new label.

Counters