Events Push
JavaScript Groovy Java Gosu
Pull request Compare This branch is 58 commits behind smaldini:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Events-push is a client-side events bus based on the superbe portable push library Atmosphere and Grails platform-core plugin for events propagation/listening. It simply allows your client to listen to server-side events and push data. It uses WebSockets by default and failbacks to Comet method if required (server not compliant, browser too old...). Events-push is a white-list broadcaster (client-side events scope is 'browser'). You will need to define which events can be propagated to server by using Events DSL to use 'browser' scope. To register listeners from client, you will need to define them too. Ie:

MyEvents.groovy >

events = {    
    'savedTodo' browser:true // allows browser push on this topic

MyService.groovy >

//will receive client events from 'saveTodo' topic
@Listener(namespace='browser') saveTodo(Map data){
  event('savedTodo', data) // will trigger registered browsers on 'savedTodo' topic

someView.gsp >

<r:require module="grailsEvents"/>
 var grailsEvents = new grails.Events("http://localhost:8080/app/");
 grailsEvents.send('saveTodo', data); //will send data to server topic 'saveTodo'
 grailsEvents.on('savedTodo', function(data){...}); //will listen for server events on 'savedTodo' topic

You can find a full sample using Events-si, RabbitMQ, BackboneJS, coffeescript and CloudFoundry in Grails Todo repository.