Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Loadrunner@danwrong
Script loader
Script loader
Dependency Manager
Thing(s) that need tohappen before otherthings can happen
Vital Statistics• http://github.com/danwrong/loadrunner• 4.6KB minified• MIT License• Used by: Phoenix, TfW
Built-in features
Load arbitrary JavaScript
using(/javascripts/app.js, /javascripts/underscore.js, function() {  _([1, 2, 3]).each(function(i) {    Application.load(i...
Define/import modules
// define with objectprovide({  original: nuttah,  booyaka: "booyaka"});
// define with a factory function (in modules/dancehall.js)provide(function(exports) {  var beenieMan = badman; function w...
using.path = /modules;using(dancehall, function(dancehall) {  console.log(dancehall.whoGotTheKeysToMaBeamer(badman))  //=>...
provide(function(exports) {  using(soundsystem, function(soundsystem) {    var beenieMan = badman;    function whoGotTheKe...
Define/import AMDModuleshttp://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition
// in modules/amd/dancehall.jsdefine([soundsystem], function(soundsystem) {  var beenieMan = badman;  function whoGotTheKe...
using.path = /modules;using(amd/dancehall, function(dancehall) {  console.log(dancehall.whoGotTheKeysToMaBeamer(badman)); ...
Under the hood
loadrunner.Dependency
var dep = new loadrunner.Dependency;dep.then(function(results){  console.log(results);});dep.then(function(results) {  con...
using()
using(thing, /javascripts/thing.js);// is the same as:new loadrunner.Combination([  new loadrunner.Module(thing),  new loa...
using.matchers.add(/.js$/, function(path) {  return new Script(     path.replace(/^$/, using.path.replace(//$/, ) + /)  );...
Building in to Loadrunner
function Template(path) {}Template.prototype = new loadrunner.Dependency;Template.prototype.start = function() {   // call...
Loadbuilder is coming• Based on Node.js, NPM module• Builds and minifies dependency trees defined with Loadrunner
Questions?
Nächste SlideShare
Wird geladen in …5
×

Loadrunner

4.430 Aufrufe

Veröffentlicht am

Brief talk on Loadrunner as given at the Twitter Front-end Summit on 4/13.

Veröffentlicht in: Technologie, Business
  • Als Erste(r) kommentieren

Loadrunner

  1. 1. Loadrunner@danwrong
  2. 2. Script loader
  3. 3. Script loader
  4. 4. Dependency Manager
  5. 5. Thing(s) that need tohappen before otherthings can happen
  6. 6. Vital Statistics• http://github.com/danwrong/loadrunner• 4.6KB minified• MIT License• Used by: Phoenix, TfW
  7. 7. Built-in features
  8. 8. Load arbitrary JavaScript
  9. 9. using(/javascripts/app.js, /javascripts/underscore.js, function() { _([1, 2, 3]).each(function(i) { Application.load(i); });});var utils = using(/javascripts/jquery.js, /javascripts/underscore.js);utils.then(function() { // do some stuff});// somewhere else in your codeutils.then(function() { // do other stuff});
  10. 10. Define/import modules
  11. 11. // define with objectprovide({ original: nuttah, booyaka: "booyaka"});
  12. 12. // define with a factory function (in modules/dancehall.js)provide(function(exports) { var beenieMan = badman; function whoGotTheKeysToMaBeamer(person) { if (person == beenieMan) { return "De girls dem suga"; } } exports({ beenieMan: beenieMan, whoGotTheKeysToMaBeamer: whoGotTheKeysToMaBeamer });});
  13. 13. using.path = /modules;using(dancehall, function(dancehall) { console.log(dancehall.whoGotTheKeysToMaBeamer(badman)) //=> "De girls dem suga"});
  14. 14. provide(function(exports) { using(soundsystem, function(soundsystem) { var beenieMan = badman; function whoGotTheKeysToMaBeamer(person) { if (person == beenieMan) { return soundsystem.play("De girls dem suga"); } } exports({ beenieMan: beenieMan, whoGotTheKeysToMaBeamer: whoGotTheKeysToMaBeamer }); });});
  15. 15. Define/import AMDModuleshttp://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition
  16. 16. // in modules/amd/dancehall.jsdefine([soundsystem], function(soundsystem) { var beenieMan = badman; function whoGotTheKeysToMaBeamer(person) { if (person == beenieMan) { return soundsystem.play("De girls dem suga"); } } return { beenieMan: beenieMan, whoGotTheKeysToMaBeamer: whoGotTheKeysToMaBeamer };});
  17. 17. using.path = /modules;using(amd/dancehall, function(dancehall) { console.log(dancehall.whoGotTheKeysToMaBeamer(badman)); //=> "De girls dem suga"});
  18. 18. Under the hood
  19. 19. loadrunner.Dependency
  20. 20. var dep = new loadrunner.Dependency;dep.then(function(results){ console.log(results);});dep.then(function(results) { console.log(results + 10);});dep.complete(15);// logs 15 and 25;dep.then(function(results) { console.log(results - 5);})// logs 10 immediatelydep.completed === true;
  21. 21. using()
  22. 22. using(thing, /javascripts/thing.js);// is the same as:new loadrunner.Combination([ new loadrunner.Module(thing), new loadrunner.Script(/javascripts/thing.js)]);
  23. 23. using.matchers.add(/.js$/, function(path) { return new Script( path.replace(/^$/, using.path.replace(//$/, ) + /) );});using.matchers.add(/^[a-zA-Z0-9_-/]+$/, function(id) { return new Module(id);});
  24. 24. Building in to Loadrunner
  25. 25. function Template(path) {}Template.prototype = new loadrunner.Dependency;Template.prototype.start = function() { // called when first callback is added // start the template load this.load(function(source) { // call complete when its done var template = this.compile(source) this.complete(template); })};using.matchers.add(/.mustache$/, function(path) { return loadrunner.Template(path);});using(example.mustache, function(template) { template.eval({ a: 1, b: 2 });});
  26. 26. Loadbuilder is coming• Based on Node.js, NPM module• Builds and minifies dependency trees defined with Loadrunner
  27. 27. Questions?

×