Fork me on GitHub
#re-frame
<
2016-12-04
>
shaun-mahood00:12:33

@andre: That diagram would have been very helpful last week :)

cmal04:12:28

@colin.yates thanks you for your kind explanation. I learned a lot from that. 👍

shaun-mahood07:12:36

Based on the changes.md file in the developbranch, am I correct that we should now be including clear-subscription-cache! in our figwheel on-jsload (or equivalent) all the time in 0.9?

cmal07:12:09

The following code is working now. This problem seems to be related to the events.cljs not be auto re-compiled. ----------- original question ---------- Hi, Is this problem related to that I did not use dispatch-sync? I have the following code and got an error of :model in component 'input-text': Expected 'string|atom'. Got '{:query "PE", :stockid "600123.sh"}' after change the first two fields' value and press 'Send Input ==>' button. My intent is to make :model filed to be "600123.sh" and dispatch a [:send-input {:query "PE" :stockid "600123.sh"}]

(defn drawer-child []
  (let [query (reagent/atom "")
        stockid (reagent/atom "")]
    (fn [{:keys [id label]}]
      [re-com/v-box
       ;; :div.drawer-child
       :children
       [[re-com/box
         :child
         [:div.drawer-child-title id]],
        [re-com/box
         :child
         [re-com/single-dropdown
          :choices conf/home-choices
          :model nil
          :placeholder "Have a choice..."
          :on-change #(reset! query %)]  ;; <== reset query
         :style
         {
          :padding "0 10px"
          }],
        [re-com/box
         :child
         [:div.stockid-input
          [:div.stockid-label "Secucode:"]
          [re-com/input-text
           :class (log @query @stockid)
           :model stockid   ;; <== Error on validating :model! My intent is to make it an atom of string, but got an hashmap. I don't know why.
           :on-change #(reset! stockid %)  ;; <== reset stockid
           :placeholder "600123.SH"]]
         :style
         {
          :padding "0 10px"
          }],
        ;; send input button
        [re-com/box
         :child
         [re-com/button
          :label "Send Input ==>"
          :on-click #(dispatch
                      [:send-input
                       {:query @query
                        :stockid @stockid}])  ;; <== dispatch an event, not work even use dispatch-sync
          :class "btn-warning"
          ]
         :style
         {
          :padding "0 10px"
          }],

        ]
       :gap "10px"
       ]
      ))
  )

andre07:12:39

And is it only me who can't find any info how to work with re-frame and figwheel?

andre07:12:28

I remember when I started to work with re-frame, I found that it was impossible to autoreload with figwheel, and since then has not looked

cmal07:12:23

@andre have you tried dirac?

cmal07:12:11

I've been working in Chrome Canary with dirac and it is amazing.

shaun-mahood16:12:38

@andre: I'll try to put something in the FAQ tomorrow for both figwheel and for global interceptors

andre16:12:23

@shaun-mahood so the idea is to re-render root view on figweel js on load?

shaun-mahood16:12:05

Yeah, and you only re-do your app-db init on the first load

shaun-mahood16:12:29

Code at https://github.com/smahood/re-frame-conj-2016 should have a config that will work

cmal16:12:52

Hi, I've encountered a strange problem now. I am currently using the reframe-template to build a demo site. I changed the value of db/default-db, and I re-run everything (lein figwheel dev, lein repl, chrome, even Emacs), but the app-db will not change. If I try to (dispatch-sync [:initialize-db]) manually, the app-db still will not change. BUT when I re-edited(even not change the value of db/default-db) the db.cljs and save and then (dispatch-sync [:initialize-db]) manually the app-db CHANGED. BUT when I try to reload chrome page, and restart lein figwheel dev, the app-db get BACK to the original value. It is very strange for me because the original value of app-state or default-db is in no where of my code now! I've tried this again and again and again, the app-db still remains the original value and will never change again except that I do the second dispatch-sync thing above. I tried to get the value of db/default-db in repl and found it remains the original value. Why? How can I deal with this problem? Thanks!

andre17:12:19

where are you looking db value?

cmal17:12:27

Even the compiled db.js file is using a correct value.

cmal17:12:56

re-frisk

cmal17:12:43

and repl

andre17:12:36

so you change db value and run figwheel but the value in re-frisk and repl is old?

cmal17:12:51

no, repl's value is new now. I don't know why. But in re-frisk is still the old.

andre17:12:47

are you looking in the panel or separate browser's window?

cmal17:12:04

I see, maybe a browser's cash rewrite the value to app-db

andre17:12:09

did you refresh page and reopen the re-frisk window?

andre17:12:30

yes. it's better to hot reload

cmal17:12:33

I re-opened browser but does not clean the cache

cmal17:12:44

I'll try that

cmal17:12:29

bingo! that is the problem! thank you @andre !

andre17:12:07

i think it can be confusing, i'll add in the todo list. because if you open re-frisk in separate window, and refresh the main app window, re-frisk window doesn't work anymore, i should make some tooltip for what

cmal17:12:21

I think the problem confusing me is about the browser cache. Is the :app-db set on somewhere in browser cache? If not, no reason that I changed the code and restart the project but the app-db still the old. Only if the browser read the cache of app-db and then my code call some event to change the app-db based on the value cached so the new app-db is flushed.

andre17:12:22

where are you looking app-db in panel or separate window?

cmal17:12:06

You mean panel or separate window of re-frisk? I am always using a seperate window. I'll try again and see whether the problem recur.

andre17:12:23

but. it doesn't matter, because the data in the app window, so you just have cached your application, re-frisk can't help here, ok, thank you

cmal17:12:03

I am not doing cache. I tried again and found that the app did not cache the state, either. I just surmised that to happen. I wonder why just now it works after I cleaned the cache. curious.

cmal17:12:49

I am going to sleep, it is 01:30. Thank you today.

andre17:12:55

@cmal have a good sleep. sorry for my english, i mean browser cashed, not you 🙂