It would be interesting if Figwheel could essentially decorate any implementation of IJavaScriptEnv
, taking on the responsibility of watching the filesystem (perhaps even delegating that to ClojureScript :watch
, and expanded :watch-fn
, and perhaps minimally calling IJavaScriptEnv -load
when Figwheel determines it is needed.
Then, for those REPLs that can participate, if IFigwheelSupport
can be extended to them, they can do further cool stuff. (Perhaps IFigwheelSupport
is actually necessary while IJavaScriptEnv
as described in the previous paragraph is insufficient, and a more fancy impl of -load
is needed?)
That way, things like the existing Node REPL could be minimally supported by Figwheel, as well as Ambly, the Browser REPL, etc.
What does IFigwheelSupport
do?
Perhaps somewhere there is a HUD interface and Figwheel can ask a REPL to display things on its HUD? An iOS or Android-specific REPL could delegate to Objective-C or Java that implement a HUD using platform-specific UI widgets.
Perhaps another thing is the "punch-through" where you add capabilities to talk to the underlying Clojure to do things.
In general though, that's all that is floating around in my mind right now: A way for Figwheel to decorate any REPL with minimal features, based on IJavaScriptEnv
, and then additional interfaces that allow them to opt into more extensive features. (Or for other people to independently extends those REPLs with those featueres, given the flexibility of Clojure).
This is interesting.
Hmmmm maybe something general like INotificationSupport?? To allow the compiler/repl a chance to notify the user of compilation completion, failure, and warnings? This is strongly tied to watch.
Or maybe just IMessageSupport and document a set of messages that come out of the compilation process?
I'm wondering if we can just use the internal compile :watch? Seems all that we need if skipping CSS reloading.
Adding something like CSS is an interesting way to see how a core system would extend. Do you add or inject a client side css-loadier lib? Do you add another layer of middleware to watch for the change? And you send the message of the change over the IMessageSupport channel?
Should reload be handled as a message from ClojureLand i.e. -load? I could almost do this by simply tracking @compiler-env changes and hooking into the :watch-fn and then calling -load.
The reloading story is interesting. I we need is a list of files that changed hopefully in load order. I wonder if I can get this from the compile/watch process. Or should I plan on getting this from the compile-env?
It would be nice for the compiler to say hey this is what changed. The regular command line REPL could benefit from this info as well as the other notifications. We could stop relying on print to deliver such important information.
Does any of this make sense? :)