Skip to content

Commit

Permalink
docs(README): Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoGentile committed Apr 18, 2018
1 parent 9f8ef42 commit 7fd1830
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This plugin can also be used standalone together with mobx.
## Requirements

- __router5 >= 5.0.0__
- __mobx >= 3.1.0__
- __mobx >= 4.0.0__

These are considered `peerDependencies` that means they should exist in your installation, you should install them yourself to make this plugin work. The package won't install them as dependencies.

Expand All @@ -26,16 +26,18 @@ npm install mobx-router5
## How it works
Before using this plugin it is necessary that you understand how [router5 works](http://router5.github.io/docs/understanding-router5.html).

Whenever you performs a router5's transition from one state to another and that transition is *started*, *canceled*, it's *successful* or it has a transition *error* this plugin exposes all this info as [mobx observables](https://mobx.js.org/refguide/observable.html) properties of the `RouterStore` class. You can then use the mobx API to **observe** and react to these **observables**:
Whenever you performs a router5's transition from one state to another and that transition is *started*, *canceled*, it's *successful* or it has a transition *error*
this plugin exposes all this info as [mobx observables references](https://mobx.js.org/refguide/observable.html) properties of the `RouterStore` class.
You can then use the mobx API to **observe** and react to these **observables**:

```javascript
@observable route // the current route
@observable previousRoute
@observable transitionRoute
@observable transitionError
@observable intersectionNode
@observable canActivate
@observable canDeactivate
@observable.ref route; // Current Route - Object
@observable.ref previousRoute; // Object
@observable.ref transitionRoute; // Object
@observable.ref transitionError; // Object
@observable.ref intersectionNode; // String
@observable.ref canActivate; // Array
@observable.ref canDeactivate; // Array

```

Expand Down Expand Up @@ -98,20 +100,6 @@ Normally it's **not necessary** to *manually* call these actions, the plugin wil

The only one probably worth calling manually (only when necessary) is `clearErrors()`: it resets the `transitionRoute` and `transitionError`.

These actions ensures that these observables properties of the store are always up-to-date with the current state:

```javascript
@observable route; // Object
@observable previousRoute; // Object
@observable transitionRoute; // Object
@observable transitionError; // Object
@observable intersectionNode; // String
@observable canActivate; // Array
@observable canDeactivate; // Array

```


### Router instance reference inside the store

When you add the plugin to the router with
Expand Down

0 comments on commit 7fd1830

Please sign in to comment.