Write a normal JavaScript function in AMD module.

3898
2
02-09-2015 09:51 PM
SanajyJadhav
Occasional Contributor II

Hello,

 

I know this question is regarding pure Dojo but still I'm asking for help because I have just started to learn JavaScript API.

 

In a custom AMD Dojo module,we write a module function like below and we call it from somewhere.

 

addMapService:function(url,mapControl){            //add map service  }, 

 

However, I want to know how we go about writing a normal Javascript function in AMD module as below;

 

function addMapService(url,mapControl){            //add map service  }

 

The reason I'm asking this, we need lot of private helper functions in AMD module,so instead of creating another helper AMD module,I'm looking for a way to write the normal JavaScript function in a module itself.

 

Cheers,

S.

0 Kudos
2 Replies
MohammedEl_Shafaey
New Contributor III

Hi

You can write your normal javascript functions in a separate js file and link it to your page and by this way all the functions in the js file will be accessible from any AMD module that will be loaded in the same page.

Although i prefer to create a helper AMD module to make your code fully object oriented.

regards

0 Kudos
SanajyJadhav
Occasional Contributor II

Thanks Mohammed.

0 Kudos