Skip to content

Commit

Permalink
[accountant] Making methods private and updating README
Browse files Browse the repository at this point in the history
This commit makes most methods private and updates the README to keep
pace and to make the library's function a little clearer.
  • Loading branch information
venantius committed Sep 14, 2015
1 parent ca62570 commit 90b85ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Accountant

Accountant is a ClojureScript library to make navigation in single-page
applications simple.
applications simple. It expects you to use [Secretary](https://github.com/gf3/secretary) to define your routes.

By default, clicking a link in a ClojureScript application that isn't a simple
URL fragment will trigger a full page reload. This defeats the purpose of using
Expand All @@ -19,7 +19,7 @@ browsers will be left behind.
Just add the following to your `project.clj`:

```clojure
:dependencies [venantius/accountant "0.1.0"]
:dependencies [venantius/accountant "0.1.1"]
```

## Usage
Expand All @@ -30,7 +30,7 @@ All you have to do to get Accountant working is the following:
(ns your-app-ns
(:require [accountant.core :as accountant]))

(accountant/configure)
(accountant/configure-navigation!)
```

...and you're good to go!
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject venantius/accountant "0.1.0"
(defproject venantius/accountant "0.1.1"
:description "Navigation for Single-Page Applications Made Easy."
:url "http://github.com/venantius/accountant"
:license {:name "Eclipse Public License"
Expand Down
10 changes: 5 additions & 5 deletions src/accountant/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
(:import goog.history.Html5History
goog.Uri))

(defn listen [el type]
(defn- listen [el type]
(let [out (chan)]
(events/listen el type
(fn [e] (put! out e)))
out))

(defn dispatch-on-navigate
(defn- dispatch-on-navigate
[history]
(let [navigation (listen history EventType/NAVIGATE)]
(go
(while true
(let [token (.-token (<! navigation))]
(secretary/dispatch! token))))))

(defn find-href
(defn- find-href
"Given a DOM element that may or may not be a link, traverse up the DOM tree
to see if any of its parents are links. If so, return the href content."
[e]
Expand All @@ -32,7 +32,7 @@
(when-let [parent (.-parentNode e)]
(recur parent)))) (.-target e)))

(defn prevent-reload-on-known-path
(defn- prevent-reload-on-known-path
"Create a click handler that blocks page reloads for known routes in
Secretary."
[history]
Expand All @@ -47,7 +47,7 @@
(. history (setToken path title))
(.preventDefault e))))))

(defn configure
(defn configure-navigation!

This comment has been minimized.

Copy link
@jessicaappelbaum

jessicaappelbaum Aug 26, 2016

Could this function be made idempotent?

We're experiencing a problem where after we call this twice (on accident) we have to press the back button twice in order to go back on our site.

Does that sound plausible?

Thanks in advance for your time and insight.

"Create and configure HTML5 history navigation."
[]
(let [history (Html5History.)]
Expand Down

0 comments on commit 90b85ac

Please sign in to comment.