CJS and AMD are the primary targets for when
, but instructions for a variety of setups are provided below.
As of version 3.0, when.js requires an ES5 environment. In older environments, use an ES5 shim such as poly or es5-shim
If you're already using RaveJS, just install when.js and start coding:
npm install --save when
orbower install --save when
var when = require('when');
-
Get it.
bower install --save when
, orgit clone https://github.com/cujojs/when
-
Configure your loader. Here is an example of how configuring the package might look:
// using requirejs
requirejs.config({
packages: [
{ name: 'when', location: '/path/to/when', main: 'when' }
]
});
// using curl.js
curl.config({
packages: {
when: { location: '/path/to/when', main: 'when' }
}
});
- Load when wherever you need it. For example, as part of a module:
define(function(require) {
var when = require('when');
// your code...
});
npm install --save when
var when = require('when');
ringo-admin install cujojs/when
var when = require('when');
ender add when
var when = require('when');
git clone https://github.com/cujojs/when
var when = require('when');
orvar when = require('path/to/when');
If you prefer not to use an AMD or CommonJS loader in your project, you can use a pre-built UMD module available in dist/browser/when[.min|.debug].js
to have a global when
available.
npm install --save when
<script src="path/to/when/dist/browser/when.js"></script>
- Or
<script src="path/to/when/dist/browser/when.min.js"></script>
for minified version - Or
<script src="path/to/when/dist/browser/when.debug.js"></script>
with when/monitor/console enabled when
will be available aswindow.when
- Other modules will be available as sub-objects/functions, e.g.
window.when.fn.lift
,window.when.sequence
. See the full sub-namespace list in the browserify build file
If you expose the whole dist/browser
folder in your application (or make sure that when[.min|.debug].js
has its corresponding *.map
file available next to it), you will have the source maps available for debugging in the browser.
Similarly to browser global environments:
npm install --save when
importScripts('path/to/when/dist/browser/when.js');
- Or
importScripts('path/to/when/dist/browser/when.min.js');
for minified version - Or
importScripts('path/to/when/dist/browser/when.debug.js');
with when/monitor/console enabled when
will be available asself.when
- Other modules will be available as sub-objects/functions, e.g.
self.when.fn.lift
,self.when.sequence
. See the full sub-namespace list in the browserify build file