In function http_response (app.js) we have:
// execute callback functions of plugins
if (response.callbacks && response.callbacks.length) { for (var i=0; i < response.callbacks.length; i++) this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]); }
This code isn't realy useful and redundant because we have response.exec. Is someone using it? I propose to replace this with something more useful:
this.triggerEvent('response'+response.action, {});
or, even better, two calls responsebefore* and responseafter*.
A.L.E.C wrote:
In function http_response (app.js) we have:
// execute callback functions of plugins if (response.callbacks && response.callbacks.length) { for (var i=0; i < response.callbacks.length; i++) this.triggerEvent(response.callbacks[i][0], response.callbacks[i][1]); }
This code isn't realy useful and redundant because we have response.exec. Is someone using it?
This is the way we suggest to implement ajax conversation with the server: http://trac.roundcube.net/wiki/Doc_Plugins#Ajaxrequestsandcallbacks
In class rcube_json_output all commands starting with "plugin." will be added to the response.callbacks list. The reason for this was to force that all these callbacks have only one single parameter in order to make things easier. This is not given with the internal commands which end up in the response.exec list and which needs to be eval'ed on the client. The latter one is legacy code and is subject to be changed once in favor of the response.callbacks mechanism.
You should revert your changes in r3650 and bring back the old events. Otherwise we'll end up with many broken plugins.
I propose to replace this with something more useful:
this.triggerEvent('response'+response.action, {});
or, even better, two calls responsebefore* and responseafter*.
I currently don't see a concrete use-case for these before* and after* events. And why do we need two of them ('responseafter' and 'responseafter'+response.action)?
~Thomas _______________________________________________ List info: http://lists.roundcube.net/dev/
On 24.05.2010 21:34, Thomas Bruederli wrote:
This is the way we suggest to implement ajax conversation with the server: http://trac.roundcube.net/wiki/Doc_Plugins#Ajaxrequestsandcallbacks
In class rcube_json_output all commands starting with "plugin." will be added to the response.callbacks list. The reason for this was to force that all these callbacks have only one single parameter in order to make things easier. This is not given with the internal commands which end up in the response.exec list and which needs to be eval'ed on the client. The latter one is legacy code and is subject to be changed once in favor of the response.callbacks mechanism.
I've missed that, but... I didn't found that someone is using this feature.
or, even better, two calls responsebefore* and responseafter*.
I currently don't see a concrete use-case for these before* and after* events. And why do we need two of them ('responseafter' and 'responseafter'+response.action)?
In this way I can execute code on response to every or just to selected action. This is not possible to bind to response of core actions using response.callbacks. In my solution you've got also an access to response object. I can imagine a plugin for measuring performance of response parsing/execution, in this case I could create handlers for 'responsebefore' (timer start) and 'responseafter' (printing time in console). Other case, let's say I want to do something after creating a folder, in this case I can bind to 'responseafter' event and check response.action or bind to 'responseaftercreate-folder'. Because I've access to response object I could parse it to know if operation was successful. I think these events are handling all possible usecases for plugin writers.
Im not quite sure what you guys are discussing, but I believe im using this feature. For instance in my compose_addressbook plugin:
JS:
// register the callback function
rcmail.addEventListener('plugin.compose_addressbook_receive', compose_addressbook_receive);
// register the callback function for the group expander
rcmail.addEventListener('plugin.compose_addressbook_receive_expand', compose_addressbook_receive_expand);
PHP:
// send the addressbook back to javascript
$rcmail->output->command('plugin.compose_addressbook_receive', array('addresses' => $contacts));
$rcmail->output->command('plugin.compose_addressbook_receive_expand', array('members' => array_unique($members), 'target' => $target));
Regards,
Cor
List info: http://lists.roundcube.net/dev/