Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created September 18, 2011 13:52
Show Gist options
  • Save Raynos/1225095 to your computer and use it in GitHub Desktop.
Save Raynos/1225095 to your computer and use it in GitHub Desktop.
mediator.on("receive:thingsFromDB", function(things) {
// how I get res here?
res.send(things);
});
app.get("/things", function(req, res) {
mediator.emit("request:thingsFromDB");
});
@tommedema
Copy link

mediator.on("receive:thingsFromDB", function(cb) {
    var things = getFromDb();
    cb(things);
});

app.get('/things', function(req, res) {
    mediator.emit("request:thingsFromDB", function(things) {
        res.send(things);
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment