Skip to content

Reactivity is hyper #67

Open
Open
@jamgold

Description

@jamgold

I love the Meteor integration, but have difficulties understanding reactivity and it's implementation.

Apparently meteor functions are running many times, even before the component is created or mounted? Here is a meteor block I have in a component. It's subscribing to items publication based on a computed query. $subscribe and itemsCursor is triggered many times, even before the component is ready or meteor is active, and I do not understand why.

created(){
 const component = this;
 component.$startMeteor();
},
meteor: {
  $subscribe: {
    items: function(){
      const component = this;
      console.log(`$subscribe mounted=${component._isMounted}`, component.query);
      return [ component.query , {limit:9} ];
    }
  },
  itemsCursor () {
    const component = this;
    const isMounted = component._isMounted;
    const meteorActive = component._meteorActive;
    // this runs several times, even before component is created or mounted
    console.log(`itemsCursor found ${Items.find().count()} items mounted=${isMounted} meteor active=${meteorActive}`);
    return Items.find({}, {
      sort: {created: -1}
    });
  },
},

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