fetch-component-data
Advanced tools
Comparing version 6.0.1 to 6.1.3
@@ -34,25 +34,25 @@ 'use strict'; | ||
function fetchComponentData(options, callback) { | ||
var _$defaults = _lodash2.default.defaults(options, defaults), | ||
store = _$defaults.store, | ||
branch = _$defaults.branch, | ||
action = _$defaults.action, | ||
location = _$defaults.location, | ||
parallelism = _$defaults.parallelism; | ||
return new _promise2.default(function (resolve, reject) { | ||
var _$defaults = _lodash2.default.defaults(options, defaults), | ||
store = _$defaults.store, | ||
branch = _$defaults.branch, | ||
action = _$defaults.action, | ||
location = _$defaults.location, | ||
parallelism = _$defaults.parallelism; | ||
var result = {}; | ||
var queue = new _queueAsync2.default(parallelism); | ||
var result = {}; | ||
var queue = new _queueAsync2.default(parallelism); | ||
return new _promise2.default(function (resolve, reject) { | ||
branch.forEach(function (branch) { | ||
var Component = branch.route.component; | ||
if (!Component) return; | ||
queue.defer(function (callback) { | ||
var Component = branch.route.component; | ||
if (!Component) return; | ||
while (Component.WrappedComponent) { | ||
Component = Component.WrappedComponent; | ||
} | ||
if (!Component.fetchData) return; | ||
while (Component.WrappedComponent) { | ||
Component = Component.WrappedComponent; | ||
} | ||
if (!Component.fetchData) return; | ||
var match = branch.match; | ||
var match = branch.match; | ||
queue.defer(function (callback) { | ||
var done = function done(err) { | ||
@@ -64,4 +64,11 @@ var res = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
}; | ||
var promise = Component.fetchData({ store: store, action: action, match: match, location: location }, done); | ||
if (promise) { | ||
var promise = void 0; | ||
try { | ||
promise = Component.fetchData({ store: store, action: action, match: match, location: location }, done); | ||
} catch (err) { | ||
return done(err); | ||
} | ||
if (promise && promise.then) { | ||
promise.then(function (res) { | ||
@@ -68,0 +75,0 @@ return done(null, res); |
{ | ||
"name": "fetch-component-data", | ||
"version": "6.0.1", | ||
"version": "6.1.3", | ||
"description": "Small util functions for Frameworkstein", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,19 +16,19 @@ import _ from 'lodash' // eslint-disable-line | ||
export default function fetchComponentData(options, callback) { | ||
const { store, branch, action, location, parallelism } = _.defaults(options, defaults) | ||
const result = {} | ||
const queue = new Queue(parallelism) | ||
return new Promise((resolve, reject) => { | ||
const { store, branch, action, location, parallelism } = _.defaults(options, defaults) | ||
const result = {} | ||
const queue = new Queue(parallelism) | ||
return new Promise((resolve, reject) => { | ||
branch.forEach(branch => { | ||
let Component = branch.route.component | ||
if (!Component) return | ||
queue.defer(callback => { | ||
let Component = branch.route.component | ||
if (!Component) return | ||
while (Component.WrappedComponent) { | ||
Component = Component.WrappedComponent | ||
} | ||
if (!Component.fetchData) return | ||
while (Component.WrappedComponent) { | ||
Component = Component.WrappedComponent | ||
} | ||
if (!Component.fetchData) return | ||
const match = branch.match | ||
const match = branch.match | ||
queue.defer(callback => { | ||
const done = (err, res={}) => { | ||
@@ -38,4 +38,12 @@ if (res) _.extend(result, res) | ||
} | ||
const promise = Component.fetchData({store, action, match, location}, done) | ||
if (promise) { | ||
let promise | ||
try { | ||
promise = Component.fetchData({store, action, match, location}, done) | ||
} | ||
catch (err) { | ||
return done(err) | ||
} | ||
if (promise && promise.then) { | ||
promise.then(res => done(null, res)).catch(err => done(err)) | ||
@@ -42,0 +50,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
13401
218