Meteor and Subscriptions

I do not understand the concept Meteor.subscribe. It is assumed that it takes records from the server and attaches them to collections with the same name, right?

[subscribe] will be a queue of incoming attributes until you declare Meteor.Collection on the client with the corresponding collection name.

So, why are different names used in the docs example ? What is the relationship between allplayers and players ?

Meteor.subscribe("allplayers");
...
// client queues incoming players records until ...
...
Players = new Meteor.Collection("players");
+1
source share
1 answer

There are two names:

  • The name of the collection ( 'players'in this case).
  • The name of the subscription ( 'allplayers'in this case).

- . , , ( ) this.set() Meteor.publish, , [ 1].

, , , . , , , , , .

[1] (, return players.find();) Meteor.publish, this.set(name) , name players .

+3

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


All Articles