Fork me on GitHub
#rum
<
2021-06-10
>
sova-soars-the-sora20:06:47

I guess I'm doing something incorrectly here...

(rum/defc image-preload < rum/reactive []
  [:div
  	(map #([:img {:src %}]) (vals setting-map))])

sova-soars-the-sora20:06:07

My issue is that on mobile the images for this javascript app do not load, so I thought I might preload them at the bottom of the page...

sova-soars-the-sora20:06:42

(def setting-map 
	{:cafe "img/cafe.jpg"
	 :livingroom "img/livingroom.png"
	 :museum "img/museum.jpg"
	 :store "img/store.jpg"
	 :park "img/park.jpg"})

sova-soars-the-sora20:06:21

I get an "invalid arity: 0

sova-soars-the-sora20:06:27

oh I can use (fn [n] but not #(%)

👍 2
Azzurite10:06:57

yeah with #(x) you're trying to call x as a function, so in this case you're trying to call a vector as a function, which you can, calling a vector as a function gets you an element at a specific index, i.e. ([1 2 3] 0) will give you 1. But you're just calling the vector without any argument, i.e. incorrect arity.

Azzurite10:06:50

with (fn [] x) you're returning x when the function is called. For both to be the same, you'd need to do (fn [] (x))