Skip to content

Commit

Permalink
removed unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmartincraig committed Aug 19, 2023
1 parent d72feeb commit 1c0937a
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 68 deletions.
3 changes: 1 addition & 2 deletions src/app/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@
[[0 0 0]])

(def default-db
{:todos (sorted-map-by >)
:app-state {:springs spring-matrix
{:app-state {:springs spring-matrix
:displacement displacement-vector}})
17 changes: 0 additions & 17 deletions src/app/fx.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,12 @@
[clojure.edn :as edn]
[re-frame.core :as rf]))

(rf/reg-cofx :time/now
(fn [cofx]
(assoc cofx :time/now (js/Date.now))))

(rf/reg-cofx :store/todos
(fn [cofx store-key]
(let [todos (edn/read-string (js/localStorage.getItem store-key))]
(rf/console :log (str "Found app state " todos))
(assoc cofx :store/todos todos))))

(rf/reg-cofx :store/app-state
(fn [cofx store-key]
(let [app-state (edn/read-string (js/localStorage.getItem store-key))]
(rf/console :log (str "Found app state " app-state))
(assoc cofx :store/app-state app-state))))

(defn store-todos [store-key]
(rf/->interceptor
:id :store/set-todos
:after (fn [context]
(js/localStorage.setItem store-key (-> context :effects :db :todos str))
context)))

(defn store-app-state [store-key]
(rf/->interceptor
:id :store/set-app-state
Expand Down
25 changes: 0 additions & 25 deletions src/app/handlers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,14 @@
(:require [re-frame.core :as rf]
[app.fx :as fx]))

(def load-todos (rf/inject-cofx :store/todos "uix-starter/todos"))
(def load-app-state (rf/inject-cofx :store/app-state "car-suspension/app-state"))
(def store-todos (fx/store-todos "uix-starter/todos"))
(def store-app-state (fx/store-app-state "car-suspension/app-state"))

(rf/reg-event-fx :app/init-db
[load-app-state]
(fn [{:store/keys [app-state]} [_ default-db]]
{:db (update default-db :app-state into app-state)}))

(rf/reg-event-fx :todo/add
[(rf/inject-cofx :time/now) store-todos]
(fn [{:keys [db]
:time/keys [now]}
[_ todo]]
{:db (assoc-in db [:todos now] todo)}))

(rf/reg-event-db :todo/remove
[store-todos]
(fn [db [_ created-at]]
(update db :todos dissoc created-at)))

(rf/reg-event-db :todo/set-text
[store-todos]
(fn [db [_ created-at text]]
(assoc-in db [:todos created-at :text] text)))

(rf/reg-event-db :todo/toggle-status
[store-todos]
(fn [db [_ created-at]]
(update-in db [:todos created-at :status] {:unresolved :resolved
:resolved :unresolved})))

(rf/reg-event-db :displacement/update-displacement
[store-app-state]
(fn [db [_ i new-displacement]]
Expand Down
24 changes: 0 additions & 24 deletions src/app/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
[emmy.env :as emmy]
[emmy.matrix :as matrix]))

(rf/reg-sub :app/db
(fn [db _]
db))

(rf/reg-sub :app/todos
(fn [db _]
(:todos db)))
Expand All @@ -25,11 +21,6 @@
(fn [app-state _]
(apply matrix/by-rows (:displacement app-state))))

(rf/reg-sub :app/degrees
:<- [:app/springs]
(fn [springs _]
(matrix/diagonal springs)))

(rf/reg-sub :app/forces
:<- [:app/springs]
:<- [:app/displacements]
Expand All @@ -45,18 +36,3 @@
:<- [:app/forces]
(fn [forces [_ i]]
(get-in forces [i 0])))


(comment
(let [
degrees (rf/subscribe [:app/degrees])
springs (rf/subscribe [:app/springs])
displacements (rf/subscribe [:app/displacements])
displacement (rf/subscribe [:app/displacement 1])
forces (rf/subscribe [:app/forces])
force (rf/subscribe [:app/force 1])
elastic-thinning (rf/subscribe [:app/elastic-thinning 0])]
@elastic-thinning)


)

0 comments on commit 1c0937a

Please sign in to comment.