I guess I'm doing something incorrectly here...
(rum/defc image-preload < rum/reactive []
[:div
(map #([:img {:src %}]) (vals setting-map))])
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...
(def setting-map
{:cafe "img/cafe.jpg"
:livingroom "img/livingroom.png"
:museum "img/museum.jpg"
:store "img/store.jpg"
:park "img/park.jpg"})
I get an "invalid arity: 0
oh I can use (fn [n] but not #(%)
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.
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))
interesting
o.O
Alright check it out: visual demonstration of japanese grammar https://japanesecomplete.com/magic-sentence made with rum ^_^