PDA

View Full Version : Accessing "Controller References" in "Application Action" code



vdemnos
24 Feb 2012, 5:22 AM
Hello,

I am having some trouble understanding why/how to use Controller Reference getters within my Application Action code (all defined on the same Controller).

Looking at the Code View for the associated Controller shows that Application Actions and Controller Actions are nearly identical. However, the 'this' instance is different...

What is the recommended approach for coding Application Actions ?

aconran
24 Feb 2012, 9:00 AM
Application Actions are for behaviors that apply to the entire application.

Controller Actions only apply to one specific controller.

In smaller applications, the denotation between the two is probably insignificant. But as your application grows you may want to segment responsibilities into specific controllers to isolate its affect on other portions of the application.

vdemnos
24 Feb 2012, 10:27 AM
Oh, ok.

What is the recommended approach for triggering communication between two controllers? My initial assumption was this would be best done by firing an Application Actions... (based on this forum thread (http://www.sencha.com/forum/showthread.php?146752-Communication-between-controllers))

Maybe I'm just missing something more obvious. Is there an existing event that is always triggered whenever a specific Container becomes 'visible' (dominant / top-most) in an application?

aconran
24 Feb 2012, 10:59 AM
What is the recommended approach for triggering communication between two controllers? My initial assumption was this would be best done by firing an Application Actions... (based on this forum thread (http://www.sencha.com/forum/showthread.php?146752-Communication-between-controllers))


This is really getting into an architectural discussion and will vary based on your application but in general yes using application events will be the best practice for this.



Maybe I'm just missing something more obvious. Is there an existing event that is always triggered whenever a specific Container becomes 'visible' (dominant / top-most) in an application?

Components will fire the activate event when they have been activated

vdemnos
24 Feb 2012, 12:25 PM
Ok, thanks for the recommendation and advice. I shall do further investigation :)