Book Image

KnockoutJS Essentials

By : Jorge Ferrando, Jorge F Ferrando
Book Image

KnockoutJS Essentials

By: Jorge Ferrando, Jorge F Ferrando

Overview of this book

Table of Contents (16 chapters)
KnockoutJS Essentials
About the Author
About the Reviewers

Using RequireJS in our project

To convert our modules into RequireJS-compatible modules, we will define them using the AMD specification. This specification says that to define a module you need to call the define function. This function receives an array that contains strings. These strings represent paths or aliases from the configuration file for each dependency (files required in the module).

The second parameter that the define function needs is a function that will return the module. This function will have dependencies from the array as arguments. The good thing with this pattern is that code inside the define function will not be executed until all dependencies are loaded. The following is what the define function will look like:

  //you can use depencencies here, not outside.
  var Module = //can be a literal object, a function.
  return Module; 

The function should always return the module variable, or...