Fork me on GitHub

When I start figwheel, I have a repl in my term, but when I connect with cider (cider-jack-in), it doesn’t connect to the repl


same in browser, I cannot evaluate (+ 2 3) in Chrome’s console


i’m trying to optimize a function and i realize that i don’t know the cost of clojure(script) functions - can anyone direct me as to where i can learn how expensive operations like map, apply, into are? (even if optimization is not the right way here, my curiosity has been piqued anyway and i’ll like an answer just to that question)


@krchia: in general clojurescript functions are normal js functions, what makes them adding more overhead is 1) use of persistent data structures 2) protocol methods dispatch 3) dynamic multi-method dispatch 4) complexity of core library methods/macros (e.g. how map, into or apply are implemented) I don’t know any source where you could learn how expensive individual operations are, because a) in advanced mode, code can be inlined/simplified by google closure :advanced optimisations b) both clojurescript and closure compiler are moving targets constantly improving I would recommend you to use general javascript performance tools from Chrome DevTools to inspect and optimise specific piece of code.


If you want to get general sense how complex code gets generated from your cljs sources, read cljs.core library functions' implementation and inspect generated javascript code.


@darwin and whoever else is listening I think came up with and intuitive way to control which browser window gets the eval in figwheel


Problem: figwheel broadcasts its evals to all listening repls with the same build id


and you get back the first response


I'm now thinking that I can use js/document.hidden as a simple and effective way to determine which tab and or client will eval the messages


basically the client that is has a tab focussed will eval the repl code


this still allows multiplexing repl commands to say different browsers or instances of browsers if that is what you want


The iphone and the the local web browser will still get and evaluate the repl messages but when operating in a single browser only the tab that is open will get it.


@bhauman: this is a nice discovery, will definitely help to improve figwheel workflow


works for tabs only, not for focus, I think, for example opening two windows side-by-side, both report document.hidden as false


that is the case


I could use last focus as a tie breaker but that could get nutsy


this doesn't fix the whole problem but it goes a long way towards intuitive sensible behavior


there is still a case where this doesn't work and that is when the window is hidden and you are still expecting eval to work


oh shoot must think harder


@bhauman: just for inspiration, in Dirac I implemented a simple string/regex matching between browser sessions and REPL instances:


you can “join” a dirac session by giving it regex or substring match, the connection is then maintained dynamically (browser session can disappear and reappear later)


that makes sense


I use only the first match, but in your case you could broadcast to all matches, and default matching strategy would be the build-id (to maintain original behaviour)


if someone wanted to target only iphone, it would match against platform in the session string


yeah I get it


if they wanted to target only specific tab on desktop, they could match url (or add a hash/param to their url, to match to)


smart and it makes sense


I'm going to let it steep in


I think a combination of ideas, a sane default where the developer doesn't have to do anything and a proactive method of selecting the client makes sense


the regex idea is as good as any


this is where I build the session string[1], you would want to add build-id and maybe some other figwheel specific info: [1]