Skip to content

Commit 5bbc3db

Browse files
author
Guillaume Chau
committed
docs: update
1 parent 2998431 commit 5bbc3db

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

README.md

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default {
3737
}
3838
```
3939

40-
#### Subscriptions
40+
### Subscriptions
4141

4242
Add an object for each subscription in a `$subscribe` object. The object key is the name of the publication and the value is either an array of parameters or a function returning an array of parameters. These subscription will be stopped when the component is destroyed.
4343

@@ -101,7 +101,7 @@ Vue.config.meteor.subscribe = function(...args) {
101101
}
102102
```
103103

104-
#### Reactive data
104+
### Reactive data
105105

106106
You can add reactive properties that update from any Meteor reactive sources (like collections or session) by putting an object for each property in the `meteor` object. The object key is the name of the property (it shouldn't start with `$`), and the value is a function that returns the result.
107107

@@ -166,7 +166,7 @@ computed: {
166166
}
167167
```
168168

169-
#### Activating and deactivating meteor data
169+
### Activating and deactivating meteor data
170170

171171
You can deactivate and activate again the meteor data on the component with `this.$startMeteor` and `this.$stopMeteor`:
172172

@@ -199,7 +199,7 @@ export default {
199199
}
200200
```
201201

202-
#### Freezing data
202+
### Freezing data
203203

204204
This option will apply `Object.freeze` on the Meteor data to prevent Vue from setting up reactivity on it. This can improve the performance of Vue when rendering large collection lists for example. By default, this option is turned off.
205205

@@ -208,6 +208,41 @@ This option will apply `Object.freeze` on the Meteor data to prevent Vue from se
208208
Vue.config.meteor.freeze = true
209209
```
210210

211+
### Without meteor option
212+
213+
**Not currently SSR-friendly**
214+
215+
With the special methods injected to the components, you can use reactive Meteor data without the `meteor` option:
216+
217+
```js
218+
export default {
219+
data () {
220+
return {
221+
limit: 5,
222+
sort: true,
223+
}
224+
},
225+
226+
created () {
227+
// Not SSR friendly (for now)
228+
this.$subscribe('notes', () => [this.limit])
229+
},
230+
231+
computed: {
232+
notes () {
233+
// Not SSR friendly (for now)
234+
return this.$autorun(() => Notes.find({}, {
235+
sort: { created: this.sort ? -1 : 1 },
236+
}))
237+
},
238+
239+
firstNote () {
240+
return this.notes.length && this.notes[0]
241+
},
242+
},
243+
}
244+
```
245+
211246
### Components
212247

213248
**Vue 2+ only**

0 commit comments

Comments
 (0)