Code Monkey home page Code Monkey logo

Comments (8)

thearabbit avatar thearabbit commented on June 15, 2024

+1, I can't use watch

  meteor: {
    $subscribe: {
      ['app.company']: [],
    },
    company() {
      return Company.findOne()
    },
  },
watch:{
   company:{
      handler(val){
           // don't work
      },
      immediate: true,
   }
}

from vue-meteor-tracker.

hluz avatar hluz commented on June 15, 2024

Maybe try this?

meteor: {
    $subscribe: {
      ['app.company']: [],
    },
    company() {
      return Company.findOne() || {}
    },
  },
watch:{
   company:{
      handler(val){
           // don't work
      },
      immediate: true,
   }
}

from vue-meteor-tracker.

dylanalizon avatar dylanalizon commented on June 15, 2024

Maybe we have to use observeChanges ? But how ? Someone has an idea please ?

from vue-meteor-tracker.

thearabbit avatar thearabbit commented on June 15, 2024

I will try soon

from vue-meteor-tracker.

mathieustan avatar mathieustan commented on June 15, 2024

I encounter the same problem. It seems like when watcher remove computed reactivity.
If I comment a watch, which are linked to a Meteor data, computed works fine.

Exemple with watch :

computed: { 
	notes() {
		return this.$autorun(() => Notes.find({}).fetch());
	}, 
	notesCount() {
		console.log(this.notes); // always undefined
		return this.notes.length;
	},
},
watch: {
	notesCount: {
		handler(count) {
			console.log(count); // undefined
		},
		immediate: true,
	}
}

Exemple WITHOUT watch :

computed: { 
	notes() {
		return this.$autorun(() => Notes.find({}).fetch());
	}, 
	notesCount() {
		console.log(this.notes.length); // return a number, works fine & reactive
		return this.notes.length;
	},
},
watch: {
	/*notesCount: {
		handler(count) {
			console.log(count); // undefined
		},
		immediate: true,
	}*/
}

from vue-meteor-tracker.

mathieustan avatar mathieustan commented on June 15, 2024

I investigate this issue.
It seems like, in _computedWatchers, our computed property looses its deps.

With just a computed property :
capture d ecran 2018-09-21 a 14 54 16

When there is a watch on this computed property:
capture d ecran 2018-09-21 a 14 53 52

@Akryum any idea why deps disappear when we introduce a watch which is related to a data from $meteor.data ?

from vue-meteor-tracker.

vbgm avatar vbgm commented on June 15, 2024

+1

from vue-meteor-tracker.

Akryum avatar Akryum commented on June 15, 2024

Duplicate of #34

from vue-meteor-tracker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.