Fork me on GitHub
#figwheel
<
2018-01-26
>
currentoor18:01:19

is there a way to execute a callback every time figwheel successfully re-compiles?

mikerod22:01:16

@currentoor call it in a fn, say it is called my.app/on-js-reload Then add :figwheel {:on-jsload "my.app/on-js-reload"} to your relevant :cljsbuild Assuming you are using Leiningen, lein-cljsbuild, and figwheel

mikerod22:01:34

I believe that does what you are asking

currentoor22:01:55

@mikerod thanks for answering, but actually i meant on the back in the JVM

mikerod22:01:04

oh 😛

currentoor22:01:45

i want to hear a ting sound when it compiles successfully and a AANG sound when it fails to re-compile

currentoor22:01:53

like boot-reload

mikerod22:01:40

Maybe you can do it in your ring handler, if you are using one

mikerod22:01:22

:figwheel {:ring-handler my.app/fig-handler} in your main :figwheel config ?

mikerod22:01:28

and do the call in that handler fn

currentoor22:01:43

when does that ring handler get called by figwheel?

currentoor22:01:51

i thought that was to load assets?

mikerod22:01:04

Some reason I thought it was recalled on each server-reload

mikerod22:01:08

I definitely could be wrong

mikerod22:01:59

Nope, sorry

mikerod22:01:01

I’m being dumb

currentoor22:01:08

no worries 😄

mikerod22:01:14

You can put things in there that happen on each request

mikerod22:01:16

not on each reload

mikerod22:01:30

I wasn’t thinking straight

mikerod22:01:35

hmmm I can’t solve your issue then hah

mikerod22:01:45

Perhaps there is a way to tag onto the watchers of figwheel though

mikerod22:01:53

to be triggered similarly

currentoor22:01:09

yeah maybe i should look into that

mikerod22:01:22

I don’t know how to find out. Maybe somewhere in its wiki doc on GitHub

mikerod22:01:28

or just reading some figwheel source hah

mikerod22:01:34

You could maybe also do a big hack and havve your JS reload handler send a request to the server to tell it it reloaded

mikerod22:01:41

and you can have that do your callback hah

mikerod22:01:30

(except I guess that’d be JS reloads, and perhaps not the server-side ones you are looking for)

currentoor22:01:09

sounds good, thanks!