Publish only update one client

hello, I have did a example at here

It is very simple, I just want to make the pub/sub works. now the problems is, when I open two same page which of course subscribe to the same publication with same collection(a local server side collection without connecting to database). when click the button, the counter updated in the same page, but the other page did not get updated. what’s wrong with it?

please look at
the client code https://github.com/imhazige/node-examples/blob/master/meteor/imports/pubsub1/client/pubsub1.js

and the publication code https://github.com/imhazige/node-examples/blob/master/meteor/imports/api/server/publications.js

here is the methods code

need help!!! I think this is a good question for a beginner.

You seem to be trying almost every possible way to do something in your repo, including mixing advanced concepts with the basics. I would honestly suggest sticking with the basics and do one thing until you completely understand it before starting something else.

I feel I have a pretty good grasp of Meteor, but I’m really struggling to follow your code and understand what you’re trying to do.

If you want to understand pub/sub, just put together the simplest possible code base to perform basic MongoDB pub/sub. When you have that working, start a brand new code base and play with the pub/sub API.

Similarly with Meteor methods - start a new project and use the basic API first. Then get to grips with how Simple-Schema works before using Validated Methods.

All the advanced stuff builds on fundamentals, which you really need to understand.

3 Likes

Hi,

Thank your response, really appreciate!

Now I have figured out what’s the problem:

1:use local collection will not trigger event across the clients. actually, the collection is local to the subscribe connection which create its cursor.

2:the publication handler .changed .xxx method will be a local collection. it also will not share update across the client.

Why I tried local collection?
because I don’t want to use mongo, I tried start the meteor without a mongo, but after these example test at https://github.com/imhazige/node-examples/tree/master/meteor
I understand, if we want use meteor, we almost “have to” use mongo, otherwise, why we should use meteor? most feature will not work.


PS:
The meteor document is detailed, but lack of example, I think one line of code will have more information than rows of words explanation.