There is nothing new here, we have already been creating event bus consumers before. Now let’s turn to what happens in the client code:
eb.send("app.markdown", text, function (err, reply) { (1)
if (err === null) {
$scope.$apply(function () { (2)
} else {
console.warn("Error rendering Markdown content: " + JSON.stringify(err));
});
Since the event bus client is not managed by AngularJS,
$scope.$apply
wraps the callback to perform proper scope life-cycle.
Admittedly, the code is very similar to its HTTP endpoint equivalent. However the benefit here does not lie in the number of lines of code.