Skip to content

Commit

Permalink
Add history actions “PUSH” and “POP”
Browse files Browse the repository at this point in the history
Closes #119
  • Loading branch information
ryanflorence committed Sep 20, 2018
1 parent 534f67c commit 1c13f8a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/crud/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
} from "./utils";
import createContext from "create-react-context";

globalHistory.listen(() => {
console.log("yooooooooooo");
globalHistory.listen(({ location, action }) => {
console.log({ location, action });
});

const InvalidateContacts = createContext();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let createHistory = (source, options) => {

let popstateListener = () => {
location = getLocation(source);
listener();
listener({ location, action: "POP" });
};

source.addEventListener("popstate", popstateListener);
Expand All @@ -58,7 +58,7 @@ let createHistory = (source, options) => {
location = getLocation(source);
transitioning = true;
let transition = new Promise(res => (resolveTransition = res));
listeners.forEach(fn => fn());
listeners.forEach(listener => listener({ location, action: "PUSH" }));
return transition;
}
};
Expand Down

0 comments on commit 1c13f8a

Please sign in to comment.