Skip to content

sbuettner/grails-events-push

 
 

Repository files navigation

grails-events-push

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"/>
<r:script>
 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
</r:script>

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

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 74.4%
  • Groovy 10.9%
  • Java 10.0%
  • Gosu 4.7%