2015-03-31 23:29:23 +02:00
|
|
|
# .cadoles-slide-title[Modularisation (5/8)]
|
2015-03-30 14:18:55 +02:00
|
|
|
|
|
|
|
**Format AMD**
|
|
|
|
|
|
|
|
> **AMD:** _Asynchronous Module Definition_
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
|
|
|
require('myModuleA', function() {
|
|
|
|
|
|
|
|
var myModuleA = {};
|
|
|
|
|
|
|
|
var localVar = 'Hello World !';
|
|
|
|
|
|
|
|
function myPrivateFunc() {
|
|
|
|
console.log('Fonction privée !')
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fonction publique, utilisable via l'exposition publique de myModule
|
|
|
|
myModuleA.myPublicFunc = function() {
|
|
|
|
console.log('Fonction publique !')
|
|
|
|
};
|
|
|
|
|
|
|
|
return myModuleA;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
require('myModuleB', ['myModuleA'], function(myModuleA) {
|
|
|
|
|
|
|
|
myModuleA.myPublicFunc();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
```
|