Last active
December 10, 2015 10:38
-
-
Save philmander/4422219 to your computer and use it in GitHub Desktop.
Injecting literal values as constructor arguments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//movies/move-finder.js | |
define(function() { | |
var MovieFinder = function(jsonUrl, numMovies, includeShortFilms) { | |
this.jsonUrl = jsonUrl; | |
this.numMovies = numMovies; | |
this.includeShortFilms = includeShortFilms; | |
}; | |
return MovieFinder; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//app-config.js | |
define(function() { | |
return { | |
protos: { | |
movieFinder : { | |
module: "movies/movie-finder", | |
args: [ | |
"http://json.movies.com", 20, true | |
] | |
} | |
} | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(["inverted", "app-config"], function(inverted, conf) { | |
var appContext = inverted.create(conf); | |
appContext.getProto("movieFinder", function(movieFinder) { | |
//movieFinder.jsonUrl == "http://json.movies.com | |
//movieFinder.numMovies == 20 | |
//movieFinder.includeShortFilms == true | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment