A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/asengupta/requirejs-q below:

asengupta/requirejs-q: A wrapper to allow loading RequireJS modules using Q promises, and a RequireJS plugin to transparently load modules which return Q promises

This project has two components you can use.

   var promise = requireQ(["some-module", "another-module"]);
   promise.spread(function(m1, m2) {
     console.log("Modules were loaded.");
  	 console.log(m1);
  	 console.log(m2);
   });

An async module which returns a Q promise:

   // async-module.js
   define([], function() {
     console.log("This does nothing either...");
  	  return Q.fcall(function() {return {data: "Again"};});
   });

Include it as below:

   require(["rq!async-module"], function(v) {
     console.log("Loaded another module");
  	 console.log(v); // v will be the JSON, not the promise
   });

Alternatively, you can use requireQ directly, without using rq at all, like so:

   var promise = requireQ(["some-module", "another-module", "async-module"]);
   promise.spread(function(m1, m2, v) {
     console.log("Modules were loaded.");
     console.log(m1);
  	 console.log(m2);
     console.log(v); // v will be the JSON
   });

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4