Comparing version 0.2.9 to 0.2.10
@@ -221,4 +221,3 @@ /** | ||
var context = self.createContext(); | ||
context.rehydrate(obj.context); | ||
callback(null, context); | ||
context.rehydrate(obj.context, callback); | ||
}); | ||
@@ -225,0 +224,0 @@ }; |
@@ -9,2 +9,5 @@ /** | ||
var objectAssign = require('object-assign'); | ||
var React = require('react'); | ||
var FluxibleComponent = React.createFactory(require('./FluxibleComponent')); | ||
var async = require('async'); | ||
require('setimmediate'); | ||
@@ -223,16 +226,34 @@ | ||
*/ | ||
FluxContext.prototype.rehydrate = function rehydrate(obj) { | ||
FluxContext.prototype.rehydrate = function rehydrate(obj, callback) { | ||
var self = this; | ||
obj.plugins = obj.plugins || {}; | ||
self._plugins.forEach(function pluginsEach(plugin) { | ||
if ('function' === typeof plugin.rehydrate) { | ||
// Send in the plugin namespace state and provide access to the application instance | ||
plugin.rehydrate(obj.plugins[plugin.name], self); | ||
var pluginTasks = this._plugins.filter(function (plugin) { | ||
return 'function' === typeof plugin.rehydrate; | ||
}).map(function (plugin) { | ||
return function (asyncCallback) { | ||
if (2 === plugin.rehydrate.length) { // Async plugin | ||
plugin.rehydrate(obj.plugins[plugin.name], asyncCallback); | ||
} else { // Sync plugin | ||
try { | ||
plugin.rehydrate(obj.plugins[plugin.name]); | ||
} catch (e) { | ||
asyncCallback(e); | ||
return; | ||
} | ||
asyncCallback(); | ||
} | ||
}; | ||
}); | ||
async.parallel(pluginTasks, function rehydratePluginTasks(err) { | ||
if (err) { | ||
callback(err); | ||
return; | ||
} | ||
self._dispatcher = self._app.createDispatcherInstance(self.getStoreContext()); | ||
self._dispatcher.rehydrate(obj.dispatcher || {}); | ||
callback(null, self); | ||
}); | ||
self._dispatcher = this._app.createDispatcherInstance(self.getStoreContext()); | ||
self._dispatcher.rehydrate(obj.dispatcher || {}); | ||
}; | ||
module.exports = FluxContext; |
{ | ||
"name": "fluxible", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "A pluggable container for isomorphic flux applications", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
86274
33
742