route-resolver
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -1,9 +0,19 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", { value: true });function routeResovler(state, isInitial) { | ||
"use strict";Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* processes the props matched from react router 2 | ||
* and calls fetch | ||
* | ||
* @param {object} props | ||
* @param {boolean} isInitial | ||
* @returns {Promise} | ||
*/ | ||
function routeResovler(props, isInitial) { | ||
if (isInitial) { | ||
return Promise.resolve();} | ||
var promises = state.routes. | ||
filter(function (route) {return route.handler.fetch;}). | ||
map(function (route) {return route.handler.fetch(state.params, state.query);}); | ||
var promises = props.components. | ||
filter(function (component) {return component.fetch;}). | ||
map(function (component) {return component.fetch(props.params, props.location.query);}); | ||
if (promises && promises.length > 0) { | ||
@@ -10,0 +20,0 @@ return Promise.all(promises);} else |
{ | ||
"name": "route-resolver", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "takes an array of matched routes and calls a fetch function if available", | ||
@@ -15,3 +15,3 @@ "main": "lib/index.js", | ||
"build": "npm-run-all clean lint babel", | ||
"test": "npm run build && npm run babel-test && istanbul cover ./script/jasmine-wrapper.js", | ||
"test": "npm run build && npm run babel-test && istanbul cover ./node_modules/@trunkclub/test-utils/lib/index.js", | ||
"watch-test": "nodemon --watch . --ext es6,json --exec 'npm run test'", | ||
@@ -25,11 +25,11 @@ "jasmine-wrapper": "./script/jasmine-wrapper.js", | ||
"devDependencies": { | ||
"@trunkclub/babel-config": "^2.0.2", | ||
"@trunkclub/eslint-config": "^1.0.0", | ||
"@trunkclub/test-utils": "^1.0.0", | ||
"babel-cli": "^6.10.1", | ||
"babel-eslint": "^6.1.0", | ||
"babel-preset-trunkclub": "^3.0.4", | ||
"eslint": "^2.13.1", | ||
"eslint-plugin-react": "^5.2.2", | ||
"eslint-watch": "^2.1.11", | ||
"istanbul": "^0.4.3", | ||
"jasmine": "^2.4.1", | ||
"jasmine-spec-reporter": "^2.4.0", | ||
"jsdom": "^8.4.0", | ||
"nodemon": "^1.9.2", | ||
@@ -36,0 +36,0 @@ "npm-run-all": "^1.5.1", |
# Route Resolver | ||
Route resolver loops through matched routes from react router and calls a static fetch function on each handler. The static fetch function should return a promise. | ||
### usage | ||
TODO |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
9612
53
8