CommonJS and AMD are the primary targets for when, but instructions for a variety of setups are provided below.
-
Get it.
bower install when,yeoman install when, orgit clone https://github.com/cujojs/when -
Configure your loader. When.js is AMD-compatible out of the box need for shims or anything. Below 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(['when', ...], function(when, ...) { ... });
npm install whenvar when = require('when');
ringo-admin install cujojs/whenvar when = require('when');
ender add whenvar when = require('when');
git clone https://github.com/cujojs/whennpm installnpm run browserifyto generatebuild/when.js- Or
npm run browserify-debugto build with when/monitor/console enabled <script src="path/to/when/build/when.js"></script>whenwill 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