What is the best practise to maintain complex structure using Pub/Sub to communicate between modules?
I finished up my last project with a lot of module that are nicely decoupled (maybe even “overdecoupled”). But if want to debug something or change event subscriptions and publishes, a lot of CTRL + F is involved to find all code parts interrested in specific event. Is there any pattern for better event based communication management? I used Marionette and its EventAggregator
as pub/sub.
You are describing the exact use case for the RequestResponse object.
https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.requestresponse.md
Handler:
var App = new Marionette.Application();
App.reqres.setHandler("foo", function(bar){
return bar + "-quux";
});
Request:
App.request("foo", "baz"); // => returns "baz-quux"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.