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:

    1. eb.send("app.markdown", text, function (err, reply) { (1)
    2. if (err === null) {
    3. $scope.$apply(function () { (2)
    4. } else {
    5. console.warn("Error rendering Markdown content: " + JSON.stringify(err));
    6. });
    1. 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.