re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
Spaceman 2020-06-22T01:14:14.487400Z

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"]]
)

Spaceman 2020-06-22T01:15:09.488100Z

But only want to call loadMap once per page load. :on-mount doesn't work

Spaceman 2020-06-22T01:19:35.489100Z

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

Spaceman 2020-06-22T01:33:19.489900Z

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

2020-06-22T01:51:50.492500Z

@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.

➕ 7
2020-06-22T01:52:18.493100Z

There is plenty of material out there which covers integrating Reagent with stuff like Google maps

2020-06-22T01:52:30.493400Z

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.

2020-06-22T01:52:42.493900Z

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.

2020-06-22T01:58:11.495500Z

Over and out

kenny 2020-06-22T16:54:35.000700Z

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)))

2020-06-22T16:59:52.001600Z

I have this one for subscription, but I guess it has the same intent?

2020-06-22T17:00:07.002100Z

At the bottom, it speaks about generic path and DRY

2020-06-22T17:00:13.002400Z

Does it answer your question?

2020-06-22T17:00:49.003Z

Otherwise there is this one from purely functional

Jakob Durstberger 2020-06-23T08:50:32.013500Z

Great stuff, thanks

p-himik 2020-06-22T17:11:17.003400Z

Can't find anything about events but there's this about subs: http://day8.github.io/re-frame/correcting-a-wrong/#a-final-faq

kenny 2020-06-22T17:12:04.003700Z

Ah yes, that was actually the exact section I had in my memory!

p-himik 2020-06-22T17:12:42.003900Z

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.

p-himik 2020-06-22T17:13:49.004100Z

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.

kenny 2020-06-22T17:14:28.004400Z

Oh yes, I have. They are also just learning Clojure so I'm sure lots doesn't sink in on the first read 🙂

p-himik 2020-06-22T17:14:52.004600Z

Oh, actually David did answer your question in the main channel, oops. There's even an additional link.

2
kenny 2020-06-22T17:16:26.004900Z

Yes, that bottom faq section has the exact piece I was looking for!

kenny 2020-06-22T17:16:41.005100Z

These guides are excellent. Will send these along as well. Thank you.