Select to view content in your preferred language

Dojo module | return variable vs dierct return of declare

441
2
Jump to solution
11-15-2013 08:31 AM
BenFousek
Deactivated User
When defining a module is there a good reason to define declare as a variable and then return the variable as opposed to returning declare directly? I see/do it both ways, and can't tell a difference. Is it the developers preference? I'd like to pick one and go with it across the board is why I ask. Thanks.

define(['dojo/declare', 'dojo/Evented'], function(declare, Evented) {   var someClass = declare([Evented], {     //blah blah   });   return someClass; });


OR

define(['dojo/declare', 'dojo/Evented'], function(declare, Evented) {   return declare([Evented], {     //blah blah   }); });
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
It's a personal preference/stylistic choice.

I too do both but my preference is to create a variable and return that as opposed to directly returning the value from declare(). I find the former more readable. Using a variable also lets you do additional things with your class before returning it if that's something you need.

View solution in original post

0 Kudos
2 Replies
derekswingley1
Deactivated User
It's a personal preference/stylistic choice.

I too do both but my preference is to create a variable and return that as opposed to directly returning the value from declare(). I find the former more readable. Using a variable also lets you do additional things with your class before returning it if that's something you need.
0 Kudos
BenFousek
Deactivated User
Thanks Derek. That's what I was thinking, just wanted to make sure. Thanks again.
0 Kudos