Is enqueuing client side actions officially supported?
jdrbc opened this issue · 1 comments
Hi there, thanks for the cool framework.
I have a long running client side process (no callout). I'd like to display a spinner while the client process runs. Here's what I've come up with:
filterListings : function(component, event, helper) {
console.log('CommunityRegistrationController.filterListings');
component.set('v.spinnerVisible', true);
var action = component.get('c.doFilterListings');
$A.enqueueAction(action);
},doFilterListings: function(component, event, helper) {
// long running JS process
component.set('v.spinnerVisible', false);
},
I've got a few questions:
- Is working with client side actions like this officially supported behavior? I don't see much documentation around getting/calling client side actions like this. Most of the documentation seems to assume that the action is a server side action. The fact that callbacks do not work on client side actions worries me.
- Would you recommend using $A.getCallback & a timeout instead?
- Is there some way to force the component to rerender? If that was the case I could do something like this:
filterListings : function(component, event, helper) {
console.log('CommunityRegistrationController.filterListings');
component.set('v.spinnerVisible', true);
component.rerender();
// long running JS process
component.set('v.spinnerVisible', false);
},
Sorry nobody ever got back to you jdrbc. I'll do my best to answer your questions.
-
No, we don't want you enqueueing client actions this way, we want you to either call a method you've added to the component, or fire an action that is linked to the controller action.
-
Yes!
-
When you do a .set() on the component, it becomes "dirty" and then will rerender. This may not work right though if you enqueueAction on a controller action. Though it will certainly work right if you fire an event or call a method set by aura:method.
Sorry again for not getting back to you sooner.