Skip to content

Commit

Permalink
Feature/85 only fetch data for active plot (#86)
Browse files Browse the repository at this point in the history
* #85 Modified trend-enter and trend-leave to signal currently viewed trend index

* #85 Keep trend index, but send trend id to server for toggling fetching observer values

* #85 Remove unused subscription
  • Loading branch information
restenb authored and ljamt committed Apr 30, 2019
1 parent d12ffc1 commit 57c2ae7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/cse_client/controller.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@
{:db (dissoc db :current-module)}
(socket-command ["signals"]))))

(k/reg-event-db ::trend-enter
(fn [db [{:keys [index]}]]
(assoc db :active-trend-index index)))
(k/reg-event-fx ::trend-enter
(fn [{:keys [db]} [{:keys [index]}]]
(let [trend-id (-> db :state :trends (get (int index)) :id)]
(merge
{:db (assoc db :active-trend-index index)}
(socket-command ["active-trend" (str trend-id)])))))

(k/reg-event-db ::trend-leave
(fn [db _]
(dissoc db :active-trend-index)))
(k/reg-event-fx ::trend-leave
(fn [{:keys [db]} _]
(merge
{:db (dissoc db :active-trend-index)}
(socket-command ["active-trend" nil]))))

(k/reg-event-db ::toggle-show-success-feedback-messages
(fn [db _]
Expand Down

0 comments on commit 57c2ae7

Please sign in to comment.