Skip to content

Instantly share code, notes, and snippets.

@philmander
Last active December 10, 2015 10:38
Show Gist options
  • Save philmander/4422082 to your computer and use it in GitHub Desktop.
Save philmander/4422082 to your computer and use it in GitHub Desktop.
Inverted intro with IOC
//app-config.js
define(function() {
return {
protos: {
movieLister: {
module: "movies/movie-lister",
args: [
"*jsonMovieFinder"
]
},
jsonMovieFinder: {
module: "movies/json-movie-finder"
args: [
"http://jsonp.movies.com/jsonp"
]
},
mongoMovieFinder: {
args: [{
host: "http://movies.com/mongo",
username: "movieapp",
password: "12345abc"
}];
}
}
};
});
//movie-app.js
require(["inverted", "app-config"], function(inverted, conf) {
//create an appcontext usiing the app config
var appContext = inverted.create(conf);
//get an instance of the MoveLister class
appContext.getProto("movieLister", function(movieLister) {
movieLister.showMovies();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment