You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-44Lines changed: 42 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -40,12 +40,12 @@ new Vue({
40
40
41
41
#### Subscriptions
42
42
43
-
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.
43
+
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.
44
44
45
45
```javascript
46
46
meteor: {
47
47
// Subscriptions
48
-
subscribe: {
48
+
$subscribe: {
49
49
// Subscribes to the 'threads' publication with no parameters
50
50
'threads': [],
51
51
// Subscribes to the 'threads' publication with static parameters
You can make your component `data` properties update from any Meteor reactive sources (like collections or session) by putting an object for each property in the `data` object. The object key is the name of the property, and the value is either a function or an object with the following attributes:
105
+
You can make your component `data` properties 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 either a function or an object with the following attributes:
106
106
107
107
-`params()` (optional), a function returning an object, which can use any *Vue* reactive property,
108
108
-`update([params])`, a function with optional `params` argument, that returns the value to update the corresponding `data` property of the component. Here you can use *Meteor* reactive sources, but **no Vue reactive property getters**. The `params` argument is the object returned by the `params()` function described above.
@@ -121,57 +121,55 @@ new Vue({
121
121
},
122
122
meteor: {
123
123
// Subscriptions
124
-
subscribe: {
124
+
$subscribe: {
125
125
// We subscribe to the 'threads' publication
126
126
'threads': []
127
127
},
128
-
data: {
129
-
// Threads list
130
-
// This will update the 'threads' array property on the Vue instance
131
-
// that we set in the data() hook earlier
132
-
// You can use a function directly if you don't need
133
-
// parameters coming from the Vue instance
134
-
threads () {
128
+
// Threads list
129
+
// This will update the 'threads' array property on the Vue instance
130
+
// that we set in the data() hook earlier
131
+
// You can use a function directly if you don't need
132
+
// parameters coming from the Vue instance
133
+
threads () {
134
+
// Here you can use Meteor reactive sources
135
+
// like cursors or reactive vars
136
+
// as you would in a Blaze template helper
137
+
// However, Vue reactive properties will not update
138
+
returnThreads.find({}, {
139
+
sort: {date:-1}
140
+
});
141
+
},
142
+
// Selected thread
143
+
// This will update the 'selectedThread' object property on component
144
+
selectedThread: {
145
+
//// Vue Reactivity
146
+
// We declare which params depends on reactive vue properties
147
+
params () {
148
+
// Here you can use Vue reactive properties
149
+
// Don't use Meteor reactive sources!
150
+
return {
151
+
id:this.selectedThreadId
152
+
};
153
+
},
154
+
// Optionally we can watch the parameters for changes in nested
155
+
// objects using the 'deep' option
156
+
deep:true,
157
+
//// Meteor Reactivity
158
+
// This will be refresh each time above params changes from Vue
159
+
// Then it calls Tracker.autorun() to refresh the result
160
+
// each time a Meteor reactive source changes
161
+
update ({id}) {
135
162
// Here you can use Meteor reactive sources
136
163
// like cursors or reactive vars
137
-
// as you would in a Blaze template helper
138
-
// However, Vue reactive properties will not update
139
-
returnThreads.find({}, {
140
-
sort: {date:-1}
141
-
});
142
-
},
143
-
// Selected thread
144
-
// This will update the 'selectedThread' object property on component
145
-
selectedThread: {
146
-
//// Vue Reactivity
147
-
// We declare which params depends on reactive vue properties
148
-
params () {
149
-
// Here you can use Vue reactive properties
150
-
// Don't use Meteor reactive sources!
151
-
return {
152
-
id:this.selectedThreadId
153
-
};
154
-
},
155
-
// Optionally we can watch the parameters for changes in nested
156
-
// objects using the 'deep' option
157
-
deep:true,
158
-
//// Meteor Reactivity
159
-
// This will be refresh each time above params changes from Vue
160
-
// Then it calls Tracker.autorun() to refresh the result
161
-
// each time a Meteor reactive source changes
162
-
update ({id}) {
163
-
// Here you can use Meteor reactive sources
164
-
// like cursors or reactive vars
165
-
// Don't use Vue reactive properties!
166
-
returnThreads.findOne(id);
167
-
},
164
+
// Don't use Vue reactive properties!
165
+
returnThreads.findOne(id);
168
166
},
169
167
},
170
168
},
171
169
});
172
170
```
173
171
174
-
You can skip the data initialization (the default value will be `null`) and the `data` property (as long as none of your meteor props is named 'data'):
172
+
You can skip the data initialization (the default value will be `null`):
0 commit comments