-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,67 @@ | ||
(ns conduit.subs | ||
(:require [re-frame.core :refer [reg-sub subscribe]])) | ||
|
||
(defn reverse-cmp ;; https://clojure.org/guides/comparators | ||
[a b] | ||
"Sort numbers in decreasing order, i.e.: calls compare with the arguments in the opposite order" | ||
(compare b a)) | ||
(defn reverse-cmp ;; https://clojure.org/guides/comparators | ||
[a b] | ||
"Sort numbers in decreasing order, i.e.: calls compare with the arguments in the opposite order" | ||
(compare b a)) | ||
|
||
(reg-sub | ||
:active-page ;; usage: (subscribe [:active-page]) | ||
(fn [db _] ;; db is the (map) value stored in the app-db atom | ||
(:active-page db))) ;; extract a value from the application state | ||
:active-page ;; usage: (subscribe [:active-page]) | ||
(fn [db _] ;; db is the (map) value stored in the app-db atom | ||
(:active-page db))) ;; extract a value from the application state | ||
|
||
(reg-sub | ||
:articles ;; usage: (subscribe [:articles]) | ||
(fn [db _] ;; db is the (map) value stored in the app-db atom | ||
(->> (:articles db) ;; ->> is a thread last macro - pass atricles as last arg of: | ||
(vals) ;; vals, just as we would write (vals articles), then pass the result to: | ||
(sort-by :epoch reverse-cmp)))) ;; sort-by epoch in reverse order | ||
:articles ;; usage: (subscribe [:articles]) | ||
(fn [db _] ;; db is the (map) value stored in the app-db atom | ||
(->> (:articles db) ;; ->> is a thread last macro - pass atricles as last arg of: | ||
(vals) ;; vals, just as we would write (vals articles), then pass the result to: | ||
(sort-by :epoch reverse-cmp)))) ;; sort-by epoch in reverse order | ||
|
||
(reg-sub | ||
:articles-count ;; usage: (subscribe [:articles-count]) | ||
(fn [db _] | ||
(:articles-count db))) | ||
:articles-count ;; usage: (subscribe [:articles-count]) | ||
(fn [db _] | ||
(:articles-count db))) | ||
|
||
(reg-sub | ||
:active-article ;; usage (subscribe [:active-article]) | ||
(fn [db _] | ||
(let [active-article (:active-article db)] | ||
(get-in db [:articles active-article])))) | ||
:active-article ;; usage (subscribe [:active-article]) | ||
(fn [db _] | ||
(let [active-article (:active-article db)] | ||
(get-in db [:articles active-article])))) | ||
|
||
(reg-sub | ||
:tags ;; usage: (subscribe [:tags]) | ||
(fn [db _] | ||
(:tags db))) | ||
:tags ;; usage: (subscribe [:tags]) | ||
(fn [db _] | ||
(:tags db))) | ||
|
||
(reg-sub | ||
:comments ;; usage: (subscribe [:comments]) | ||
(fn [db _] | ||
(->> (:comments db) | ||
(vals) | ||
(sort-by :epoch reverse-cmp)))) | ||
:comments ;; usage: (subscribe [:comments]) | ||
(fn [db _] | ||
(->> (:comments db) | ||
(vals) | ||
(sort-by :epoch reverse-cmp)))) | ||
|
||
(reg-sub | ||
:profile ;; usage: (subscribe [:profile]) | ||
(fn [db _] | ||
(:profile db))) | ||
:profile ;; usage: (subscribe [:profile]) | ||
(fn [db _] | ||
(:profile db))) | ||
|
||
(reg-sub | ||
:loading ;; usage: (subscribe [:loading]) | ||
(fn [db _] | ||
(:loading db))) | ||
:loading ;; usage: (subscribe [:loading]) | ||
(fn [db _] | ||
(:loading db))) | ||
|
||
(reg-sub | ||
:filter ;; usage: (subscribe [:filter]) | ||
(fn [db _] | ||
(:filter db))) | ||
:filter ;; usage: (subscribe [:filter]) | ||
(fn [db _] | ||
(:filter db))) | ||
|
||
(reg-sub | ||
:errors ;; usage: (subscribe [:errors]) | ||
(fn [db _] | ||
(:errors db))) | ||
:errors ;; usage: (subscribe [:errors]) | ||
(fn [db _] | ||
(:errors db))) | ||
|
||
(reg-sub | ||
:user ;; usage: (subscribe [:user]) | ||
(fn [db _] | ||
(:user db))) | ||
:user ;; usage: (subscribe [:user]) | ||
(fn [db _] | ||
(:user db))) |