[SOLVED] Where to put calculation logic


#1

Hey there,
i’m reading and watching Tutorials about Meteor since 1-2 Weeks. I’ve learned a lot about how to structure a meteor app regarding server and client side code, accounts, security etc.
What i could not figure out:
Where do i put the calculation logic properly?

For example:
A user puts data in a form and the data is saved in the database. Depending on this input data i want to do several calculations by putting the data through lets say a chaining of around 20 Methods, and finally display some results.

At the moment i have all of these Methods inside the file where the Template.displayResults.helper is.
When i put them in another file they don’t get recognized, i think because of the wrapper Meteor puts around.

So where do i put it?

Thanks in advance!
Vin


#2

Meteor doesn’t deny you to define a global function and call from another file.

// first_file.js
myFn = function () { console.log('hello')}
var mySecondFn = function () {console.log('hello second')}

// other_file.js
myFn(); // outputs 'hello'
mySecondFn(); //throws error

#3

Thank you!
This works :smile: