View Full Version : Execute an interceptor function on a controller method
abcdef
14 Dec 2011, 3:41 PM
I am looking to execute a certain piece of code before a certain method is called on any of my controllers.
Say:
Ext.define('S.controller.someController', {
extend: 'Ext.app.Controller',
init: function() {
...
},
someMethod: function() {
...
}
});
I need to log to console every time the method 'someMethod' is called on any of my controllers.
What is the best way to achieve this?
Please help! Thanks!
friend
15 Dec 2011, 7:14 AM
It looks like you just created an overridden/extended base Controller, on which you can now base all of your other application Controllers. Just extend your S.controller.someController class and you're done:
Ext.define('S.controller.MyController1', {
extend: 'S.controller.someController',
views: [<...>],
init: function() {
this.control({
<...>
});
});
Ext.define('S.controller.MyController2', {
extend: 'S.controller.someController',
views: [<...>],
init: function() {
this.control({
<...>
});
});
abcdef
15 Dec 2011, 12:46 PM
It looks like you just created an overridden/extended base Controller, on which you can now base all of your other application Controllers. Just extend your S.controller.someController class and you're done:
Ext.define('S.controller.MyController1', {
extend: 'S.controller.someController',
views: [<...>],
init: function() {
this.control({
<...>
});
});
Ext.define('S.controller.MyController2', {
extend: 'S.controller.someController',
views: [<...>],
init: function() {
this.control({
<...>
});
});
Ended up doing that. Thanks!
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.