I call a js function using component-did-mount\:
(def load-map (with-meta identity
{:component-did-mount
loadMap}))
(defn map []
[load-map [:div {:id "this-div"} "hello"]]
)
But only want to call loadMap once per page load. :on-mount doesn't work
loadMap can't be called directly on the page load in an effects handler because this-div needs to be mounted before loadMap is called because loadMap accesses the div using the this-div id
the error is:
You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.
cj @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k__MfQzY&callback=initMap:138
ij @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k__MfQzY&callback=initMap:135
google.maps.Load @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap:14
(anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap:227
(anonymous) @ js?key=AIzaSyD1r7IEvvf6w8FlHu3k_hP_oJwW4_MfQzY&callback=initMap:227
@pshar10 I can see that Thomas Heller has given you a dressing down in another channel and has threatened to start ignoring you. I can assure you, I have been ignoring you in this channel for well over two weeks. Your questions and approach is aggressive and demanding, and you don't seem to do the slightest bit of research before demanding that volunteers on this and other channels help you.
There is plenty of material out there which covers integrating Reagent with stuff like Google maps
It would take you 1 min of googling to figure it out. But instead you cross post this same question to three channels and then aggressively demand volunteer answers in a way which has certainly annoyed Thomas and I can assure you as annoyed me.
The stupid thing is that there is a page on EXACTLY this subject in the re-frame docs. Just do some research. Don't demand anything from anyone here. And learn to ask good questions.
Over and out
Can someone point me to the place in the re-frame docs that talks about creating events that represent user intent, not generic code ops. I cannot seem to find the appropriate section. For example, to avoid doing something like the below. We're bringing some new folk on and one has started doing something like this 🙂
(rf/reg-event-db
::assoc
(fn [db [_ path val]]
(assoc-in db path val)))
I have this one for subscription, but I guess it has the same intent?
At the bottom, it speaks about generic path and DRY
Does it answer your question?
Otherwise there is this one from purely functional
https://purelyfunctional.tv/guide/database-structure-in-re-frame/
Great stuff, thanks
Can't find anything about events but there's this about subs: http://day8.github.io/re-frame/correcting-a-wrong/#a-final-faq
Ah yes, that was actually the exact section I had in my memory!
But notice that it talks about keeping the views simple. So I'd say that the same applies to events.
Also, it means that it's perfectly fine to have such subs/events as e.g. signal subs and events that are used only by the :dispatch
effect. Just don't use them in views.
I would advise to just give the new folk the link to the documentation and ask them to read through it. :) It's a good read, and while not everything will be remembered right away, a certain familiarity with the concepts will be developed.
Oh yes, I have. They are also just learning Clojure so I'm sure lots doesn't sink in on the first read 🙂
Oh, actually David did answer your question in the main channel, oops. There's even an additional link.
Yes, that bottom faq section has the exact piece I was looking for!
These guides are excellent. Will send these along as well. Thank you.