Fork me on GitHub
#re-frame
<
2019-05-02
>
dumrat12:05:59

hi guys, I have a simple cell grid (say 100 * 100) using a <table> which I want to change and update say every 50ms. So I trigger an event every 50ms which updates the grid. It seems to me that I can't get this rate of animation. It's slowed down. relevant code:

(ns ant.views
  (:require
   [re-frame.core :as re-frame]
   [ant.subs :as subs]
   [ant.events :as ev]
   ))

(defn main-panel []
  (let [grid (re-frame/subscribe [::subs/grid])]
    (into [:table {:style {:border "1px solid red"}}]
          (for [row @grid]
            (into [:tr]
                  (for [cell row]
                    [:td {:width "5px" :height "5px"
                          :style {:backgroundColor (if (= cell 1) "black" "white")}}]))))))

(defn dispatch-timer-event
  []
  (let [now (js/Date.)]
    (re-frame/dispatch [::ev/timer now])))

(defonce do-timer (js/setInterval dispatch-timer-event 50))
::subs/grid returns a vector of vectors with dimensions 100*100. What can I do to improve performance in such a case? Should I drop re-frame event flow and just manipulate js directly?

dumrat12:05:06

Thanks @jahson. Will have a look.

abdullahibra12:05:31

Hello guys, i'm at situation which has multiple dropdown menus which is depending on each other, so based on the option i select on dropdown#1 i load suitable data into dropdown#2, i was able to creating New model from this type of form, but Editing isn't straightforward, what do you guys suggest ?

jahson13:05:51

What do you mean by “editing”?

abdullahibra13:05:17

Edit the dropdown menus with the data

abdullahibra13:05:02

suppose i have 2 dropdown menus and the second dropdown data depend on the first, when i select option from dd#1 i got data loaded into dd#2

abdullahibra13:05:28

now i have both selected data of dd#1 and dd#2

abdullahibra13:05:09

is it straightforward to load these values ad default with data for both dd#1 and dd#2

abdullahibra13:05:34

i always get dd#2 empty

abdullahibra13:05:48

because i need to select any values from dd#1 to get data loaded

abdullahibra14:05:00

i'm not sure if you got what i mean

jahson14:05:43

So your question is ’how to load data to dd#2 by default`?

abdullahibra14:05:31

my code actually do it but there was a simple bug and i have fixed and everything works

👍 8