figwheel

general discussion about figwheel, specific discussions in #figwheel-main and #lein-figwheel
currentoor 2018-01-26T18:53:19.000700Z

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

2018-01-26T22:14:16.000228Z

@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

2018-01-26T22:14:34.000192Z

I believe that does what you are asking

currentoor 2018-01-26T22:14:55.000258Z

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

2018-01-26T22:15:04.000142Z

oh 😛

currentoor 2018-01-26T22:15:45.000317Z

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

currentoor 2018-01-26T22:15:53.000407Z

like boot-reload

2018-01-26T22:16:40.000063Z

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

2018-01-26T22:17:22.000638Z

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

2018-01-26T22:17:28.000195Z

and do the call in that handler fn

currentoor 2018-01-26T22:17:43.000125Z

when does that ring handler get called by figwheel?

currentoor 2018-01-26T22:17:51.000260Z

i thought that was to load assets?

2018-01-26T22:18:04.000224Z

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

2018-01-26T22:18:08.000006Z

I definitely could be wrong

2018-01-26T22:18:59.000137Z

Nope, sorry

2018-01-26T22:19:01.000153Z

I’m being dumb

currentoor 2018-01-26T22:19:08.000204Z

no worries 😄

2018-01-26T22:19:14.000092Z

You can put things in there that happen on each request

2018-01-26T22:19:16.000031Z

not on each reload

currentoor 2018-01-26T22:19:23.000071Z

right

2018-01-26T22:19:30.000331Z

I wasn’t thinking straight

2018-01-26T22:19:35.000485Z

hmmm I can’t solve your issue then hah

2018-01-26T22:19:45.000275Z

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

2018-01-26T22:19:53.000369Z

to be triggered similarly

currentoor 2018-01-26T22:20:09.000635Z

yeah maybe i should look into that

2018-01-26T22:20:22.000333Z

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

2018-01-26T22:20:28.000110Z

or just reading some figwheel source hah

2018-01-26T22:21:34.000248Z

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

2018-01-26T22:21:41.000542Z

and you can have that do your callback hah

2018-01-26T22:22:30.000168Z

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

currentoor 2018-01-26T22:59:09.000022Z

sounds good, thanks!