Description
Example
Given a view function a in a Klipse ClojureScript snippet like
(defn a-view []
[:span "I am a view!"])
And a hiccup form b in a Klipse reagent snippet like
[a-view]
When you edit a to anything different like "I have been updated!"
then b will NOT be re-rendered and the user still sees the old string "I am a view!"
. This is really confusing for a 'live-coding' tutorial.
Actual Behaviour
b as a dependent on a does not get re-evaluated every time a changes.
Expected Behaviour
b as a dependent on a does get re-evaluated every time a changes.
Simple Suggested Solution
On change handler first re-evaluate self editor (i.e. the editor that changed) as it is now.
Second, re-evaluate every other editor that is not self.
It must be every editor snippet and not just reagent as any different language can interact and cause dependent effects on the page e.g. JavaScript -> CLJS -> CLJS -> Reagent etc.
This fixes the most obvious buggy behaviour that confuses users.
Future More Complex Solution to Consider
With more complex examples there may be trees of of dependencies that would still exhibit the buggy behaviour depending on execution order because for example
- c depends on b depends on a.
- a is changed by the user
- a is re-evaluated
- c is re-evaluated by above simple fix
- b is re-evaluated
- c is now in a state using an outdated result of b because of execution order.
This is a harder problem to solve.
You might be able to brute force it by just evaluating everything twice, but that is not a very elegant solution.
Or Klipse users could be provided with a way to build the dependency graph via metadata as Klipse cannot possibly derive this from the code snippets themselves without additional help from the developer.