Fork me on GitHub
#rum
<
2017-08-31
>
Niki08:08:03

@pez yes mixins are a way to go

Niki08:08:22

do it in :will-mount or :did-mount, clean up in :will-unmount

Niki08:08:29

that way it’ll be only installed once per component deploy

Niki08:08:55

usually it’s a good idea to tie these thing to component lifecycle anyways

Niki08:08:12

memoize to make sure fn only fires once is a terrible idea :)

pez08:08:36

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

Niki08:08:31

mixins get state passed in

Niki08:08:48

if you get (:rum/args state) you’ll get component arguments vector

pez08:08:31

Wonderful! Thanks!

Niki08:08:39

from there, you have exactly the same stuff as inside render method