Force dependencies in autorun


I have an autorun that needs to be run when a collection changes but the collection is not used in the autorun, instead an external function is called.

this.autorun(() => {
  const data = Data.find()
  data.forEach(v => { console.log()})

refresh : () => {       
    const data = Data.find()
    data.forEach (...)

The only way I found to make the autorun react to a change in the data collection was to add the useless line

  data.forEach(v => { console.log()})

Is there a better way to do that ?


Could you explain a bit more what you are trying to achieve ?
I don’t understand what get_collection is, and why it is called both in your autorun and refresh function. BTW, what is your refresh function for ?


[removed get_collection : name => collection]

It’s because provides 2 callbacks to update it’s content

  • get_data() : tells full calendar where to get the data
  • refresh() : tells full calendar to rerun get_data

Therefore my code looks like this

get_data : () { 
   const data = Data.find().fetch()
   // give data to

autorun () => {
  const data = Data.find()
  data.forEach(v => { console.log()}) // if not present, autorun doesn't run


This behaviour is documented here:

If you read through the methods and their reactive properties, you could use the equally useless (although slightly less annoying) line:


As @vjau says - what are you trying to achieve? You may be able to use observe/observeChanges to rerun the refresh.


I need to call refresh() every time the data changes in order for to refresh it’s display.
I will try to do it with observe