-
-
Save mxriverlynn/21e84f7786d968eba00d to your computer and use it in GitHub Desktop.
broker channel vs broker instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var filtersChannel = Postal.channel("filters"); | |
function FilterController(options){ | |
this.region = options.region; | |
filtersChannel.subscribe("add", (filter) => this.showFilter(filter)); | |
} | |
FilterController.prototype.showFilter = function(filter){ | |
var view = new FilterView(filter); | |
this.region.show(view); | |
} | |
FilterController.prototype.addFilter = function(){ | |
var addView = new AddFilterView(); | |
addView.on("add", (f) => filtersChannel.publish("add", f)); | |
this.region.show(addView) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FilterController(options){ | |
this.region = options.region; | |
this.filtersChannel = new Backbone.Wreqr.EventAggregator(); | |
filtersChannel.on("add", (filter) => this.showFilter(filter)); | |
} | |
FilterController.prototype.showFilter = function(filter){ | |
var view = new FilterView(filter); | |
this.region.show(view); | |
} | |
FilterController.prototype.addFilter = function(){ | |
var addView = new AddFilterView(); | |
addView.on("add", (f) => filtersChannel.trigger("add", f)); | |
this.region.show(addView) | |
} |
Thanks a lot for your helpful blog post: "Message Brokers, Channels And JavaScript Zombies" :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In line 5, I think it should be:
this.filtersChannel.on("add", (filter) => this.showFilter(filter));
Is it correct?