Skip to content

Commit

Permalink
fix: switch subscribe back to listen
Browse files Browse the repository at this point in the history
  • Loading branch information
alisd23 committed Apr 9, 2017
1 parent b5ddc82 commit 80bad54
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ And the following [history methods](https://github.com/mjackson/history#navigati

returns an *enhanced* history object with the following **additional methods**:

- **subscribe(*listener*)**
Subscribes to any changes in the store's `location` observable
- **listen(*listener*)**
Listen to any changes in the store's `location` observable
**Returns** an unsubscribe function which destroys the listener
```js
const unsubscribeFromStore = history.subscribe((location, action) => console.log(location.pathname));
const unsubscribeFromStore = history.listen((location, action) => console.log(location.pathname));

history.push('/test1');
unsubscribeFromStore();
Expand Down
4 changes: 2 additions & 2 deletions src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const syncHistoryWithStore = (history, store) => {
const unsubscribeFromHistory = history.listen(handleLocationChange);
handleLocationChange(history.location);

const subscribe = (listener) => {
const listen = (listener) => {
const onStoreChange = (change) => {
listener(store.location, history.action);
};
Expand All @@ -28,7 +28,7 @@ export const syncHistoryWithStore = (history, store) => {
};
const unsubscribe = () => unsubscribeFromHistory();

history.subscribe = subscribe;
history.listen = listen;
history.unsubscribe = unsubscribe;

return history;
Expand Down
3 changes: 1 addition & 2 deletions types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import { History, Location, UnregisterCallback } from 'history';

declare namespace MobxReactRouter {

export interface SynchronizedHistory extends History {
unsubscribe?: UnregisterCallback;
}

export class RouterStore {
history?: SynchronizedHistory;
history?: History;
location?: Location;
}

Expand Down

0 comments on commit 80bad54

Please sign in to comment.