Skip to content

webrocker/ext.mq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

Synopsis

Ext.MQ is a simple message queue implementation with a webservice gateway for easy remoting. It simplyfies loose coupling between components and webservice communication a lot.
I really didnt’t like the Ext.Direct mechanism, so I developed this small class to connect a Ext application to a Zend Framework or Symfony backend.

Setup

Just include ext.mq.js in Your html file and setup the webservice base url if it is different than /:


<script include="src/ext.mq.js"></script> <script language="javascript"> MQ.webserviceurl = '/api/'; </script>

Publishing messages

<script language="javascript">
    MQ.publish('ui.detailscreen.show', {id: 'webrocker'});
</script>

Subscribing messages

<script language="javascript">
    MQ.subscribe(/ui\.detailscreen\.(.*)/, myDetailscreenHandler);
</script>

Webservice gateway

Messages starting with webservice. are automagically converted into AJAX calls and the responses will be converted to messages, too.

<script language="javascript">
    MQ.publish('webservice.ressource.user.create', {id: 'webrocker'});
</script>

This message will translate into an AJAX call to /ressource/user/create/.
In case of success the result will be JSON-decoded and the resulting object will be sent in the message webservice.ressource.user.create.success.
If an error occurs the result will be sent in the message webservice.ressource.user.create.failure.

To implement an universal handler for webservice failures you can simply subscribe the whole namespace starting with webservice and ending with failure as follows:


<script language="javascript"> MQ.subscribe(\webservice/.(.*)/.failure\, myhandlerfunc); </script>

If you need another URL scheme, just overwrite the MQ.urlgenerator method.

About

Message Queue implementation for Ext.Core / Ext.JS with webservice gateway for easy remoting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published