├── .gitmodules ├── smart.json ├── package.js └── README.md /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "when"] 2 | path = when 3 | url = git://github.com/cujojs/when.git 4 | -------------------------------------------------------------------------------- /smart.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "when", 3 | "description": "cujojs's lightweight CommonJS Promises/A and when() implementation", 4 | "homepage": "https://github.com/awwx/meteor-when", 5 | "author": "Andrew Wilcox", 6 | "version": "1.7.1r1", 7 | "git": "git://github.com/awwx/meteor-when.git" 8 | } 9 | -------------------------------------------------------------------------------- /package.js: -------------------------------------------------------------------------------- 1 | Package.describe({ 2 | summary: "cujojs's lightweight CommonJS Promises/A and when() implementation" 3 | }); 4 | 5 | Package.on_use(function (api) { 6 | api.add_files( 7 | [ 'when/when.js' 8 | , 'when/delay.js' 9 | , 'when/timeout.js' 10 | , 'when/sequence.js' 11 | , 'when/pipeline.js' 12 | , 'when/parallel.js' 13 | , 'when/apply.js' 14 | ], 15 | ['client', 'server'] 16 | ); 17 | }); 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | when 2 | ==== 3 | 4 | cujojs's lightweight CommonJS Promises/A 5 | [when library](https://github.com/cujojs/when), 6 | packaged for Meteor. 7 | 8 | If you don't have fibers, promises are the next best thing for 9 | avoiding thickets of deeply nested callbacks in your code! 10 | 11 | 12 | Use 13 | --- 14 | 15 | $ mrt add when 16 | 17 | This adds `when`, `when_delay`, `when_timeout`, `when_sequence`, 18 | `when_pipeline`, `when_parallel`, and `when_apply` to the global 19 | namespace. 20 | 21 | For example, the API documentation for 22 | [when/delay](https://github.com/cujojs/when/blob/master/docs/api.md#whendelay) 23 | says: 24 | 25 | var delay, delayed; 26 | 27 | delay = require('when/delay'); 28 | 29 | // delayed is an unresolved promise that will become resolved 30 | // in 1 second with the value 123 31 | delayed = delay(123, 1000) 32 | 33 | With `when_delay` in the global namespace, the code would be written 34 | like this: 35 | 36 | var delayed; 37 | 38 | // delayed is an unresolved promise that will become resolved 39 | // in 1 second with the value 123 40 | delayed = when_delay(123, 1000) 41 | --------------------------------------------------------------------------------