Skip to content

Options API: functions in meteor object cannot access other properties #80

Open
@rickynaps

Description

@rickynaps
<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 -->

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions