flux-router-component
Advanced tools
Comparing version 0.0.6 to 0.1.0
@@ -9,3 +9,4 @@ /** | ||
NavLink: require('./lib/NavLink'), | ||
RouterMixin: require('./lib/RouterMixin') | ||
}; | ||
RouterMixin: require('./lib/RouterMixin'), | ||
navigateAction: require('./actions/navigate') | ||
}; |
@@ -9,3 +9,3 @@ /** | ||
NavLink, | ||
ACTION_NAVIGATE = 'NAVIGATE', | ||
navigateAction = require('../actions/navigate'), | ||
debug = require('debug')('NavLink'); | ||
@@ -15,7 +15,7 @@ | ||
dispatchNavAction: function (e) { | ||
var dispatcher = this.props.dispatcher; | ||
var context = this.props.context; | ||
debug('dispatchNavAction: action=NAVIGATE path=' + this.props.href + ' params=' + JSON.stringify(this.props.navParams)); | ||
if (dispatcher) { | ||
if (context) { | ||
e.preventDefault(); | ||
dispatcher.dispatch(ACTION_NAVIGATE, { | ||
context.executeAction(navigateAction, { | ||
type: 'click', | ||
@@ -30,5 +30,5 @@ path: this.props.href, | ||
render: function() { | ||
var router = this.props.router; | ||
if (!this.props.href && this.props.name && router) { | ||
this.props.href = router.makePath(this.props.name, this.props.navParams); | ||
var context = this.props.context; | ||
if (!this.props.href && this.props.name && context && context.makePath) { | ||
this.props.href = context.makePath(this.props.name, this.props.navParams); | ||
} | ||
@@ -35,0 +35,0 @@ return this.transferPropsTo( |
@@ -8,3 +8,3 @@ /** | ||
var History = require('./History'), | ||
ACTION_NAVIGATE = 'NAVIGATE', | ||
navigateAction = require('../actions/navigate'), | ||
EVT_PAGELOAD = 'pageload', | ||
@@ -23,3 +23,3 @@ EVT_POPSTATE = 'popstate', | ||
var self = this, | ||
dispatcher = self.props.dispatcher, | ||
context = self.props.context, | ||
hash, | ||
@@ -34,10 +34,10 @@ history; | ||
// for the route represented by the hash fragment. | ||
if (dispatcher && !history.hasPushState() && (hash = history.getHash())) { | ||
dispatcher.dispatch(ACTION_NAVIGATE, {type: EVT_PAGELOAD, path: hash}); | ||
if (context && !history.hasPushState() && (hash = history.getHash())) { | ||
context.executeAction(navigateAction, {type: EVT_PAGELOAD, path: hash}); | ||
} | ||
self._routerPopstateListener = function (e) { | ||
if (dispatcher) { | ||
if (context) { | ||
var path = history.getPath(); | ||
dispatcher.dispatch(ACTION_NAVIGATE, {type: EVT_POPSTATE, path: path, params: e.state}); | ||
context.executeAction(navigateAction, {type: EVT_POPSTATE, path: path, params: e.state}); | ||
} | ||
@@ -57,3 +57,3 @@ }; | ||
} | ||
var nav = newState.route.navigate || newState.navigate; | ||
var nav = newState.route.navigate; | ||
if (nav.type !== EVT_POPSTATE && nav.type !== EVT_PAGELOAD) { | ||
@@ -60,0 +60,0 @@ this._routerHistory.pushState(nav.params || null, null, newState.route.path); |
{ | ||
"name": "flux-router-component", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "Router-related React component and mixin for applications with Flux architecture", | ||
@@ -24,4 +24,3 @@ "main": "index.js", | ||
"debug": "^1.0.0", | ||
"react": "^0.10.0", | ||
"routr": "^0.0.1" | ||
"react": "^0.11.1" | ||
}, | ||
@@ -39,3 +38,3 @@ "devDependencies": { | ||
"precommit-hook": "^1.0.2", | ||
"react-tools": "^0.10.0" | ||
"react-tools": "^0.11.1" | ||
}, | ||
@@ -42,0 +41,0 @@ "jshintConfig": { |
@@ -15,3 +15,3 @@ # 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) | ||
links, | ||
dispatcher = this.props.dispatcher; // this is the Flux dispatcher object | ||
context = this.props.context; // this should have a router instance and an executeAction function | ||
pages = [ | ||
@@ -32,3 +32,3 @@ { | ||
<li className="navItem"> | ||
<NavLink href={page.url} dispatcher={dispatcher}> | ||
<NavLink href={page.url} context={context}> | ||
{page.text} | ||
@@ -50,6 +50,6 @@ </NavLink> | ||
## RouterMixin | ||
`RouterMixin` is a React mixin to be used by appication's top level React component to: | ||
`RouterMixin` is a React mixin to be used by application's top level React component to: | ||
* manage browser history when route changes, and | ||
* dispatch `NAVIGATE` action via flux dispatcher on window `popstate` events | ||
* execute navigate action and then dispatch `CHANGE_ROUTE` event via flux dispatcher on window `popstate` events | ||
@@ -56,0 +56,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
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
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
36505
2
19
255
1
+ Addedenvify@2.0.1(transitive)
+ Addedreact@0.11.2(transitive)
- Removedroutr@^0.0.1
- Removedenvify@1.2.1(transitive)
- Removedisarray@0.0.1(transitive)
- Removedpath-to-regexp@0.2.51.9.0(transitive)
- Removedreact@0.10.0(transitive)
- Removedreverend@0.3.1(transitive)
- Removedroutr@0.0.1(transitive)
Updatedreact@^0.11.1