Kinda like that .... hmm, not the best example
Give me a minute ... I'll quickly get a better example
Imagine you wanted to capture all windows resize events ... always ... you'd like hook that event, maybe in
core.clj like this ...
(.addEventListener js/window "resize" (fn [event] (dispatch[:resize xxx])))
You would quite literally put that code in core.cljs outside of any functions and then, when you code was loading, you'd hook the event outside of any event handlers
Why? Because you only need to do it once
And then keep the hook in place through the entire life of the program
I'd imagine your scenario would be the same.
You want to set up an
on-message callback which will do a`dispatch` (much like my resize example above)
And that on-message callback needs to be setup as the program boots, and is never removed
That's what i meant by mainline it. Just cause the event to be hooked turning code loading. Don't particularly worry about causing it to happen in effects, because it is not something you need to turn "on" and then "off"1👍
Decided to check out the meaning of the verb "mainline":
Kinda funny given that such a global statement can be considered "dirty" in some sense.
transitive verb; slang: to take by or as if by injecting into a principal vein intransitive verb; slang: to mainline a narcotic drug
It is slang which carries connotations of a fast, crude but effective way of making something happen. Effective in a brute force way, not an elegant way. And yes, it is a term from the 60s and 70s regarding heroin injection. You sometimes hear people talking about mainlining a Netflix season (binge watching).
yes that is exactly what i was looking for! i wasn't sure what was the "ideal" place to put that
(.addEventListener ,,,) .
thanks for the detailed guidance! ❤️
is there some recommended way to deal with css in re-frame/shadow?
Herb is a layer above garden so you can benefit both1👍
there is also a #css channel
As far as I'm aware, re-frame and shadow-cljs don't have anything special for CSS and don't affect your preferred workflow in any way. So you can use whatever you'd use without them.
this is my first foray into this kind of frontend development so i don't know what i can use with this setup in the first place
In this case, #clojurescript might be a more appropriate place to ask - it has 10 times more people than here.
ok i'll do that, thanks
i use roosta/herb and found it really interesting
very simple and powerful
that looks exciting, gonna check it out! thanks!
you also have https://github.com/khmelevskii/emotion-cljs which was announced recntly on #reagent channel1👍1💯
i'll try both and see which works better with what i'm trying to do
roosta/herb is really nice since it use simple functions