Meteor: display a list of current users for a document

I have a list of documents in the meteor, access to which is allowed only to authorized users. This is similar to Google docs. Is there an easy way to get a list of users who are currently viewing them?

I was thinking of including the currentUsers field in my mongodb object and deleting / deleting users whenever users are viewing or stop viewing the component. This seems like a strange way to do this, as the data is stored and probably error prone, as it does not exactly represent the users who are currently viewing the component at a time

https://stackoverflow.com/a/4646262/how-to-start-string-in-javascript/2326235#6113327 https://stackoverflow.com/questions/1015287/ ... is what I'm looking for, but the answer is a bit old, and I'm not sure how to use sockjs or. If someone can provide a working example that will be great.

Any help is much appreciated!

+6
source share
2 answers

You can easily find that like this -

Tracker.autorun(function() { if (Meteor.user()) { Meteor.subscribe('userList'); } }); 

More details can be found here.

0
source

There are several options:

DIY Solution - Saving Data in a Collection

flatulence status of the package https://github.com/mizzao/meteor-user-status

package mrt: spy (which seems to be outdated, but maybe you can build on top of it) https://atmospherejs.com/mrt/spy

socket.io https://atmospherejs.com/joncursi/socket-io-client

+4
source

Source: https://habr.com/ru/post/1015282/


All Articles