Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Adding Commands And Request/Response From Backbone.Wreqr #267

merged 3 commits into from Oct 4, 2012


None yet
4 participants

derickbailey commented Oct 3, 2012

Recently I extracted Marionette's EventAggregator in to the Backbone.Wreqr plugin. Along with the EventAggregator, this plugin provides a basic Command framework and Request/Response framework - all of which are important in creating scalable systems of loosely coupled components.

The dev branch of Marionette is already set up to use Backbone.Wreqr for it's EventAggregator. With this pull request, I want to get feedback on how I've integrated the Commands and RequestResponse object in to Marionette's Application object as well.

This allows simple commands to be registered and executed:

MyApp = new Marionette.Application();

MyApp.commands.register("foo", function(){
  console.log("foo was executed");

MyApp.execute("foo"); // => outputs "foo was executed" to the console

and for simple request/response scenarios to be handled:

MyApp = new Marionette.Application();

MyApp.reqres.register("foo", function(){
  return "response to foo request";

MyApp.request("foo"); // => returns "response to foo request"

There are docs in the pull request which outline a little more detail on the use, as well as point back to the Wreqr plugin for more information.

All feedback is appreciated.

andyl commented Oct 3, 2012

Looking forward to using req/res and commands.

Not a fan of the name 'wreqr' - no idea what it means - looks like a cat walked on the keyboard.

Are developers going to have to install a bunch of plugins to get started with Marionette? If so, that could be a barrier to adoption.


derickbailey commented Oct 3, 2012

Yeah, there was quite a bit of discussion on how best to approach the multiple plugins bit. We're planning on making it as easy as possible by giving people a single .zip file as a "getting started" package, which will include everything you need to get up and running. Then we'll also allow people to piece it together themselves.

here's the full discussion: https://groups.google.com/forum/#!topic/backbone-marionette/hEq0XLu71ys

and the message w/ the outline of what we'll be doing: https://groups.google.com/d/msg/backbone-marionette/hEq0XLu71ys/pzxYPHl8OtQJ


jsoverson commented Oct 3, 2012

I think this is great and will prevent some of the abuse of a pub/sub channel.

My only concern is for AMD users, since they can't rely on requiring an application usefully without circular issues. It's just as solvable as it was for the app vent but the solutions might need to have higher profile in the docs since now there will need to be a separate command module to replicate this behavior.


derickbailey commented Oct 3, 2012

I definitely want to make this as easy as possible for AMD users. Having it baked in to the App object is really just a convenience. Apps can create their own Commands, RequestResponse, and EventAggregator directly from Backbone.Wreqr and pass those around through AMD as needed.

Would you see that more as a wiki change, or core documentation? Also, what would that documentation look like, in terms of the information it provides?


TheCloudlessSky commented Oct 3, 2012

What the does Wreqr mean/stand for? I can sort of see "request/response", but couldn't get a clue from the README.


derickbailey commented Oct 3, 2012

Nothing particularly clever or special. But yeah, it comes from Request/Response ... ReqRes ... ReqR ... Wrecker ... Wreqr.

@derickbailey derickbailey added a commit that referenced this pull request Oct 4, 2012

@derickbailey derickbailey Merge pull request #267 from marionettejs/wreqr
Adding Commands And Request/Response From Backbone.Wreqr

@derickbailey derickbailey merged commit 3e494fc into dev Oct 4, 2012

1 check passed

default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment