Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

Commit

Permalink
remove dependency on rackt/history
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkvasnicak committed Jan 6, 2016
1 parent b2f30c1 commit 5103800
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 2,15 @@

[![Circle CI](https://circleci.com/gh/michalkvasnicak/routex.svg?style=svg)](https://circleci.com/gh/michalkvasnicak/routex)

Simple router for [Redux](https://github.com/gaearon/redux) universal applications. Can be used with [React](https://github.com/facebook/react) too.

**This library is experimental and it not tested in production!! Use at your own risk! Pull requests are welcome**
Simple router for [Redux](https://github.com/rackt/redux) universal applications. Can be used with [React](https://github.com/facebook/react) too.

## Installation

`npm install routex`

**Routex requires history^1.0.0 package to be installed**
## Requirements

**Routex needs some abstraction over browser history, we recommend to use [rackt/history^1.0.0](https://github.com/rackt/history)**

## Usage

Expand Down Expand Up @@ -194,6 194,26 @@ router.run('/where-you-want-to-go', { /* query params object */});
- signature is same as in the `onEnter`
- function used to determine if router can transition from this route (can be used as guard, ...) to a new route
- **this function is called only on `transitionTo action` and not on popState event (back and forward browser buttons)**

- **`HistoryObject:`** (`Object`):
- abstraction over browser history
- **`listen`** (`Function(Function(LocationObject))`) -
- method used to register history change events listeners (pop and push)
- **`pushState`** (`Function(state, path)`)
- pushes state for given path
- **`state`** (`?Object`) - state stored for given path
- **`path`** (`String)` - full path with query parameters
- **`replaceState`** (`Function(state, path)`)
- replaces current state with given state and path
- **`state`** (`?Object`) - state stored for given path
- **`path`** (`String)` - full path with query parameters

- **`LocationObject:`** (`Object`):
- abstraction over current location
- **`action`** (`String`) - `POP` or `PUSH`
- **`state`** (`?Object`) - current state of location
- **`pathname`** (`String`) - pathname without query parameters
- **`search`** (`String`) - search part of path (query parameters as string)

### React components

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 28,6 @@
"test": "npm run lint && mocha --compilers js:babel/register --recursive"
},
"peerDependencies": {
"history": "^1.3.0",
"redux": "^2.0.0 || ^3.0.0",
"react-redux": "^2.0.0 || ^3.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions src/Router.js
Original file line number Diff line number Diff line change
@@ -1,7 1,6 @@
import Route from './Route';
import { normalizeRouteDefinition, runRouteHandlers, resolveComponents } from './utils/routeUtils';
import { resolveWithFirstMatched } from './utils/routerUtils';
import { Actions } from 'history';
import invariant from 'invariant';
import { RouteNotFoundError } from './errors';
import { createHref, parseQuery } from './utils/urlUtils';
Expand Down Expand Up @@ -73,7 72,7 @@ export default class Router {
_handleChange(location) {
this.location = location;

if (location.action === Actions.POP) {
if (location.action === 'POP') {
// on handle pop state (we are moving in history)
// just match route and call change success because we are assuming that everything has been already resolved
// so just change route
Expand Down

0 comments on commit 5103800

Please sign in to comment.