vue-meteor-tracker
vue-meteor-tracker copied to clipboard
Options API: functions in meteor object cannot access other properties
<script>
export default {
data() {
return {
selectedThreadId: 'test',
};
},
computed: {
testComputed() {
return 'testComputed';
},
},
meteor: {
$subscribe: {
threads: [],
},
meteorTestComputed() {
// returns undefined
return this.testComputed;
},
testSubReady() {
// this.$subReady.threads == undefined
if (this.$subReady.threads) {
console.log('test If');
}
},
threads() {
// Works as expected.
return Threads.find(
{},
{
sort: { date: -1 },
}
);
},
threadsTest() {
// Returns undefined
return this.threads;
},
selectedThread() {
// Doesn't work as expected.
const test = this.selectedThreadId;
// test == undefined
// The same happens with properties in computed and meteor sections.
return Threads.findOne(this.selectedThreadId);
},
},
};
</script>
<!--
computed
can access meteor properties
cursor is not reactive
meteor
cursor is reactive
cannot access computed, meteor or data properties
can access this correctly -->
Same here, with:
- vue 3.3.4
- meteor 2.12
We can't access data or computed properties inside the meteor block.
I had to change the component to composition API