Global functions inside Tracker.autorun


#1

I defined global functions on the lib folder but i cant use it in Tracker.autorun because it says that the function is undefined/.


#2

Can we see the code where you define and use these functions?


#3

Meteor.myStatusFunctions = {
DisableStatus : function() {

  },
 
  InsertStatus : function(text, favorite, photo, isActive) {

  },
 
  InsertTimofon : function(timeofon) {

      });
      //statusListObserver.refresh();
  },
 
  GetLastStatus :  function() {
      return statusList.findOne({
          owner: Meteor.userId()
      }, {
          sort: {
              lastActive: -1
          }
      });
  },
  ReplaceStatus : function(status) {

  },

}


#4

its in the lib folder to load before the tracker function


#5

So that should work, but if you’re relying on lib/ then you may be running Meteor in “classic” (pre-ES2015 import/export) mode. In which case you may still have issues with load order. Check the Guide for more information.

BTW, if you wrap your code in triple backticks like this, it gets formatted properly:

```
paste your code
in here
```

#6

Thank you :slight_smile: moving the folder that reads the global functions from client/lib to client solved it.