With the lastest version of Require, a new config object was introduced, the shim
.
http://requirejs.org/docs/api.html#config-shim
That allows Amplify to now be used within AMD projects.
Have Fun!
With the lastest version of Require, a new config object was introduced, the shim
.
http://requirejs.org/docs/api.html#config-shim
That allows Amplify to now be used within AMD projects.
Have Fun!
define(["amplify", "someModule"], function (amplify, someModule) { | |
var app = { | |
init: function () { | |
amplify.publish("do-it"); | |
} | |
}; | |
return app; | |
}); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>AmplifyJS with RequireJS</title> | |
</head> | |
<body> | |
<h1>Amplify</h1> | |
<script src="js/require-jquery.js" data-main="js/main"></script> | |
</body> | |
</html> |
require.config({ | |
paths: { | |
"amplify": "lib/amplify.min" | |
}, | |
shim: { | |
"amplify": { | |
deps: ["jquery"], | |
exports: "amplify" | |
} | |
} | |
}); | |
require(['app'], function (app) { | |
app.init(); | |
}); |
define(["amplify"], function (amplify) { | |
var someModule = function () { | |
amplify.subscribe("do-it", this.doIt); | |
}; | |
someModule.prototype.doIt = function () { | |
console.log("It's done"); | |
}; | |
return new someModule(); | |
}); |