@pez yes mixins are a way to go
do it in :will-mount or :did-mount, clean up in :will-unmount
that way it’ll be only installed once per component deploy
usually it’s a good idea to tie these thing to component lifecycle anyways
memoize to make sure fn only fires once is a terrible idea :)
@tonsky: Thanks. I do not like that idea myself. 🙂 I did solve it using a mixin at first, but then ran into problems for the conditional guarding the install. There is state in an atom that I need to check in deciding if the listener should be installed or not. I couldn’t figure out how to feed that decision into the mixin, And trying to deref the atom threw errors. Is there a particular part of the README I should look at?
mixins get state
passed in
if you get (:rum/args state)
you’ll get component arguments vector
Wonderful! Thanks!
from there, you have exactly the same stuff as inside render method