Subscribe and Publish
Closed this issue · 1 comments
faavictoriano commented
I have a sample apps like this, there a problem on subscribing a message..
I run on android, i replace localhost to the ip of my meteor server and its connected and i can send message to the server but in getting message in server and i would like to display it on GUI theres and error.
faavictoriano commented
in my native:
let self = this;
console.log('subscribe');
ddp.subscribe('messages', [])
.then(() => {
let messagesObserver = ddp.collections.observe(() => {
let messages = [];
if (ddp.collections.messages) {
messages = ddp.collections.messages.find({});
console.log(ddp.collections.messages);
}
return messages;
});
this.setState({messagesObserver: messagesObserver})
messagesObserver.subscribe((results) => {
this.setState({messages: results});
this.refs.invertible.scrollTo(0);
})
})
in my server:
//publish to client and subscribe
Meteor.publish('messages', function() {
console.log('Publishing Messages', Messages.find().count());
return Messages.find();
});