Comparing version 1.3.0-alpha.1 to 1.3.0
# Change Log | ||
## 1.3.0 | ||
### Enhancement | ||
* [#494] Remove setImmediate from rehydration promise | ||
## 1.2.0 | ||
@@ -4,0 +10,0 @@ |
@@ -214,7 +214,9 @@ /** | ||
.then(function (contextValue) { | ||
// Ensures that errors in callback are not swallowed by promise | ||
setImmediate(callback, null, contextValue); | ||
callback(null, contextValue); | ||
}, function (err) { | ||
// Ensures that errors in callback are not swallowed by promise | ||
setImmediate(callback, err); | ||
callback(err); | ||
})['catch'](function (err) { | ||
setImmediate(function () { | ||
throw err; | ||
}); | ||
}); | ||
@@ -221,0 +223,0 @@ } |
{ | ||
"name": "fluxible", | ||
"version": "1.3.0-alpha.1", | ||
"version": "1.3.0", | ||
"description": "A pluggable container for isomorphic flux applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,19 +17,20 @@ /** | ||
function callAction (actionContext, action, payload, done) { | ||
// Use a promise to force the action to be called async | ||
var executeActionPromise = Promise.resolve().then(function () { | ||
// Assume the action returns a promise since it doesn't take a callback | ||
if (action.length < 3) { | ||
return action(actionContext, payload); | ||
} | ||
// Return a nested promise to wrap the action invocation so its result | ||
// passed to its callback can be captured | ||
return new Promise(function (resolve, reject) { | ||
action(actionContext, payload, function (err, result) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
var executeActionPromise = new Promise(function (resolve, reject) { | ||
setImmediate(function () { | ||
try { | ||
var syncResult = action(actionContext, payload, function (err, result) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result); | ||
} | ||
}); | ||
if (isPromise(syncResult)) { | ||
syncResult.then(resolve, reject); | ||
} else if (action.length < 3) { | ||
resolve(syncResult); | ||
} | ||
}); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
@@ -39,18 +40,12 @@ }); | ||
if (done) { | ||
// Once our promise (and any nested promises) fully settle, call the | ||
// `done()` callback provided to us and pass either the result or error | ||
executeActionPromise | ||
.then(function (result) { | ||
done(null, result); | ||
}, done) | ||
['catch'](function (err) { | ||
// Ensures that thrown errors in the `done()` callback above are | ||
// not swallowed by promise | ||
setImmediate(function () { | ||
throw err; | ||
}); | ||
.then(function(result) { | ||
// Ensures that errors in callback are not swallowed by promise | ||
setImmediate(done, null, result); | ||
}, function (err) { | ||
// Ensures that errors in callback are not swallowed by promise | ||
setImmediate(done, err); | ||
}); | ||
} | ||
// Finally return our original promise with the result of calling the action | ||
return executeActionPromise; | ||
@@ -57,0 +52,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
45319
751