flux-router-component
Advanced tools
Comparing version 0.1.0 to 0.2.0
var debug = require('debug')('navigateAction'); | ||
module.exports = function (payload, done) { | ||
if (!this.router || !this.router.getRoute) { | ||
module.exports = function (context, payload, done) { | ||
if (!context.router || !context.router.getRoute) { | ||
debug('no router available for navigate handling'); | ||
@@ -9,6 +9,5 @@ return; | ||
debug('executing', payload); | ||
var route = this.router.getRoute(payload.path, {navigate: payload}), | ||
newPageName = (route && route.config.page) || null; | ||
var route = context.router.getRoute(payload.path, {navigate: payload}); | ||
if (!newPageName) { | ||
if (!route) { | ||
var err = new Error('Url does not exist'); | ||
@@ -20,4 +19,19 @@ err.status = 404; | ||
debug('dispatching CHANGE_ROUTE', route); | ||
this.dispatch('CHANGE_ROUTE', route); | ||
done(); | ||
context.dispatch('CHANGE_ROUTE_START', route); | ||
var action = route.config && route.config.action; | ||
if (!action) { | ||
context.dispatch('CHANGE_ROUTE_SUCCESS', route); | ||
done(); | ||
return; | ||
} | ||
// Execute route handler | ||
context.executeAction(action, route, function (err) { | ||
if (err) { | ||
context.dispatch('CHANGE_ROUTE_FAILURE', route); | ||
} else { | ||
context.dispatch('CHANGE_ROUTE_SUCCESS', route); | ||
} | ||
done(err); | ||
}); | ||
}; |
{ | ||
"name": "flux-router-component", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Router-related React component and mixin for applications with Flux architecture", | ||
@@ -12,4 +12,4 @@ "main": "index.js", | ||
"cover": "node node_modules/istanbul/lib/cli.js cover --dir artifacts -- ./node_modules/mocha/bin/_mocha tests/unit/ --recursive --reporter spec", | ||
"lint": "./node_modules/.bin/jshint lib tests", | ||
"test": "./node_modules/.bin/mocha tests/unit/ --recursive --reporter spec" | ||
"lint": "jshint lib tests", | ||
"test": "mocha tests/unit/ --recursive --reporter spec" | ||
}, | ||
@@ -29,2 +29,3 @@ "author": "Lingyan Zhu <lingyan@yahoo-inc.com", | ||
"chai": "^1.9.1", | ||
"coveralls": "^2.11.1", | ||
"grunt": "^0.4.0", | ||
@@ -31,0 +32,0 @@ "grunt-cli": "^0.1.0", |
@@ -1,2 +0,2 @@ | ||
# flux-router-component [![Build Status](https://travis-ci.org/yahoo/flux-router-component.svg?branch=master)](https://travis-ci.org/yahoo/flux-router-component) [![Dependency Status](https://david-dm.org/yahoo/flux-router-component.svg)](https://david-dm.org/yahoo/flux-router-component) | ||
# flux-router-component [![Build Status](https://travis-ci.org/yahoo/flux-router-component.svg?branch=master)](https://travis-ci.org/yahoo/flux-router-component) [![Dependency Status](https://david-dm.org/yahoo/flux-router-component.svg)](https://david-dm.org/yahoo/flux-router-component) [![Coverage Status](https://coveralls.io/repos/yahoo/flux-router-component/badge.png?branch=master)](https://coveralls.io/r/yahoo/flux-router-component?branch=master) | ||
This package provides navigational React components and router React mixin for applications built with [Flux](http://facebook.github.io/react/docs/flux-overview.html) architecture. Please check out [examples](https://github.com/yahoo/flux-router-component/tree/master/examples) of how to use these components. | ||
@@ -51,3 +51,3 @@ | ||
* manage browser history when route changes, and | ||
* execute navigate action and then dispatch `CHANGE_ROUTE` event via flux dispatcher on window `popstate` events | ||
* execute navigate action and then dispatch `CHANGE_ROUTE_START` and `CHANGE_ROUTE_SUCCESS` or `CHANGE_ROUTE_FAILURE` events via flux dispatcher on window `popstate` events | ||
@@ -54,0 +54,0 @@ |
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
45010
22
268
0
12