Skip to content
This repository was archived by the owner on Oct 24, 2021. It is now read-only.

Commit 4310121

Browse files
committed
Document publication strategies
1 parent 91bc8b8 commit 4310121

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

code

Submodule code updated 166 files

source/api/pubsub.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,36 @@ messages. When you change rooms by calling `Session.set('currentRoom',
260260
'newRoom')`, Meteor will subscribe to the new room's chat messages,
261261
unsubscribe from the original room's chat messages, and continue to
262262
stay subscribed to your private messages.
263+
264+
## Publication strategies
265+
266+
Once you start scaling your application you might want to have more control on how the data from publications is being handled on the client.
267+
There are three publications strategies:
268+
269+
#### SERVER_MERGE
270+
`SERVER_MERGE` is the default strategy. When using this strategy, the server maintains a copy of all data a connection is subscribed to.
271+
This allows us to only send deltas over multiple publications.
272+
273+
#### NO_MERGE_NO_HISTORY
274+
The `NO_MERGE_NO_HISTORY` strategy results in the server sending all publication data directly to the client.
275+
It does not remember what it has previously sent to it will not trigger removed messages when a subscription is stopped.
276+
This should only be chosen for special use cases like send-and-forget queues.
277+
278+
#### NO_MERGE
279+
`NO_MERGE` is similar to `NO_MERGE_NO_HISTORY` but the server will remember the IDs it has
280+
sent to the client so it can remove them when a subscription is stopped.
281+
This strategy can be used when a collection is only used in a single publication.
282+
283+
You can import the publication strategies from `DDPServer`.
284+
285+
```js
286+
import { DDPServer } from 'meteor/ddp-server'
287+
288+
const { SERVER_MERGE, NO_MERGE_NO_HISTORY, NO_MERGE } = DDPServer.publicationStrategies
289+
```
290+
291+
You can use the following methods to set or get the publication strategy for publications:
292+
293+
{% apibox "setPublicationStrategy" %}
294+
295+
{% apibox "getPublicationStrategy" %}

0 commit comments

Comments
 (0)