We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to apply for this job!

Login or register to start contributing with an article!

Login or register
to see more jobs from this company!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Engineers who find a new job through JavaScript Works average a 15% increase in salary 🚀

Dependent Snippets Should Re-eval on Changes

Issue closed
Pull requests: 0
Contributors: 1
Level: Intermediate
  • Clojure
  • $100
Issue closed
Pull requests: 0
Contributors: 1
Level: Intermediate
  • Clojure
  • $100

On GitHub

Klipse is a Javacript plugin for embedding interactive code snippets in tech blogs. A simple client-side code evaluator pluggable on any web page: clojure, ruby, javascript, python, scheme, es2017, jsx, brainfuck, c++, reagent, lua, ocaml, reasonml, prolog, common lisp
More info >

Issue posted by: 
superstructor's avatar

Isaac Johnston

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.

    Use Open Source Issues to hire or get hired

    On GitHub

    Klipse is a Javacript plugin for embedding interactive code snippets in tech blogs. A simple client-side code evaluator pluggable on any web page: clojure, ruby, javascript, python, scheme, es2017, jsx, brainfuck, c++, reagent, lua, ocaml, reasonml, prolog, common lisp
    More info >

    Issue posted by: 
    superstructor's avatar

    Isaac Johnston

    Use Open Source Issues to hire or get hired

    Dependent Snippets Should Re-eval on Changes
    View on GitHub