You use this-as:
(this-as thisname
(whatever thisname))
where you name this what you want with thisname
Cheers
On Fri, Jan 25, 2013 at 1:46 PM, Ari wrote:
> Additionally, ".each()" is another option --
>
> (defn listen-to-links
> [links]
> (.each links
> (fn [idx, el]
>
Additionally, ".each()" is another option --
(defn listen-to-links
[links]
(.each links
(fn [idx, el]
(.log js/console el
However, how does one reference "this" within the anonymous (or defined)
function?
On Wednesday, January 23, 2013 11:45:13 PM UTC-5, Evan Mezeske
Oops, I should never type code straight into an email window, without
REPLing it first... X_X
I left in the "links" argument to map. This is probably closer to what I
meant:
(defn listen-to
[links]
(doseq [link links]
(.log js/console link)))
On Wednesday, January 23, 2013 8:39:51 PM
When you want to iterate over things and perform a side-effecty action for
each one (logging is a side effect, as would be adding event listeners to
DOM nodes, changing CSS classes, etc), doseq is usually the clearest thing
to do:
(defn listen-to
[links]
(doseq [link links]
(.log js/con
map is lazy so your console log is never done.
use (doall ...)
Dave
On Thursday, 24 January 2013 12:38:37 UTC+11, Ari wrote:
>
> Hi,
>
> The following clojurescript code is *supposed* to identify all anchor tags
> and print them (originally, I was trying to attach listeners and
> callbacks)