express - Anyway to implement Meteor like data subscription in Node.js -
i using express.js 1 of projects, basically, trying achieve simple:
- the page displays list of entries pulled data mongodb collection
- when user adds new entry, client side jquery collects input , fires ajax call server script
- server code adds data mongodb collection
- server signals client re-render templating code hence list updated
where having problem #4, mentioned, client re-render template updated data, instead of manipulating dom using jquery.
i have tried using socket.io, using .ajax, plus have pass res variable around can res.render mess...
with meteor.js, data hot push (subscription) done automatically, there must way express.js, right? has done before? please!!!
without work run meteor server following:
/server/main.js
collectionname = new meteor.collection("collectionname"); meteor.publish("some_name", function() { return collectionname.find(); });
then have simple nodejs app
npm install ddp
app.js
var ddpclient = require('ddp'); var connection = var ddpclient = new ddpclient({ host: "localhost", port: 3000, //port , ip of meteor server }); connection.connect(function(err) { connection.subscribe('some_name'); }); ddpclient.on('message', function (msg) { console.log("ddp message: " + msg); });
then when add in 'collectionname' collection in express app. not optimal (since have meteor app in between express app). gets job done.
Comments
Post a Comment