How to use when.defer:
GitHub: wishmouse/schools
9973 9974 9975 9976 9977 9978 9979 9980 9981 9982
var transformer = function (func_promise) { return function (/* ... */) { var args = arguments; return result_transformer(when(func_promise, function (func) { var d = when.defer(); func.apply(null, append(args, function (err, val) { if (err) { d.reject(err); } else {
How to use when.try:
GitHub: wishmouse/schools
12374 12375 12376 12377 12378 12379 12380 12381 12382
when.resolve = Promise.resolve; // Create a resolved promise when.reject = Promise.reject; // Create a rejected promise when.lift = lift; // lift a function to return promises when['try'] = attempt; // call a function and return a promise when.attempt = attempt; // alias for when.try when.iterate = Promise.iterate; // DEPRECATED (use cujojs/most streams) Generate a stream of promises when.unfold = Promise.unfold; // DEPRECATED (use cujojs/most streams) Generate a stream of promises
How to use when.reject:
GitHub: namgk/dnr-editor
51 52 53 54 55 56 57 58 59 60
try { storageModule = moduleSelector(runtime.settings); settingsAvailable = storageModule.hasOwnProperty("getSettings") && storageModule.hasOwnProperty("saveSettings"); sessionsAvailable = storageModule.hasOwnProperty("getSessions") && storageModule.hasOwnProperty("saveSessions"); } catch (e) { return when.reject(e); } if (!!storageModule.projects) { var projectsEnabled = false; if (runtime.settings.hasOwnProperty("editorTheme") && runtime.settings.editorTheme.hasOwnProperty("projects")) {
14
73
0
See more examples
How to use when.settle:
GitHub: namgk/dnr-editor
100 101 102 103 104 105 106 107 108 109
} else { callback.call(node); } } if (promises.length > 0) { return when.settle(promises).then(function() { if (this._context) { return context.delete(this._alias||this.id,this.z); } });
14
73
0
See more examples
How to use when.resolve:
138 139 140 141 142 143 144 145 146 147
ee.emit('close',0); },10) return ee; }); var addModule = sinon.stub(registry,"addModule",function(md) { return when.resolve(nodeInfo); }); installer.installModule("this_wont_exist").then(function(info) { info.should.eql(nodeInfo);
14
73
0
See more examples
How to use when.promise:
GitHub: namgk/dnr-editor
86 87 88 89 90 91 92 93 94 95
var node = this; for (var i=0;i<this._closeCallbacks.length;i++) { var callback = this._closeCallbacks[i]; if (callback.length > 0) { promises.push( when.promise(function(resolve) { var args = []; if (callback.length === 2) { args.push(!!removed); }
14
73
0
See more examples
How to use when.all:
165 166 167 168 169 170 171 172 173 174
} } } return when.all(promises).then(function() { return gitTools.stageFile(project.path,files); }).then(function() { return gitTools.commit(project.path,"Create project files",getGitUser(user)); }).then(function() {