Publication with Cursors

Understand the concept of cursors and reactive data sources.

We'll cover the following

Data publication in MeteorJS involves making a subset of data available to the client, as we saw two lessons prior. This process uses DDP.

Cursor

Cursors are reactive data sources. A data source is termed reactive when an action or a function depends on it. The useTracker function watches documents in a cursor for change and automatically reruns if they’re changed.

On the client, retrieving a cursor’s documents with fetch inside a reactive computation like useTracker for the first time makes Meteor register a dependency on the underlying data that watch it for changes.

Any change made to the collection that changes the documents in a cursor triggers a recomputation. To disable reactivity in a MeteorJS cursor, simply pass {reactive: false} to find on the client. Mongo.Collection.find({},{reactive: false}).fetch();

Get hands-on with 1200+ tech skills courses.