Lighttable repl-eval on timeout

88 views
Skip to first unread message

Camilo Roca

unread,
Aug 28, 2015, 5:46:48 AM8/28/15
to Light Table Discussion
Hello guys,

I was wondering if any of you could help me with something.

Sometimes when I am using the repl in Lighttable my repl just hangs because some of the evaluations actually take a lot of time to finish. If I am correctly, currently LT evaluates everytime that the user press a key stroke.

What I would like to do is to make LT evaluate on a timeout after the last key stroke, lets say 300ms after I finished typing.

That way, the LT will only re-evaluate a code once the user "finishes" (stopped) typing something, which might indicate that he is waiting for a result.

Is there any way to do this directly and easy in LT or do I need to write a plugin for that?

Any helps and advice are welcome :)

Magnus Rundberget

unread,
Aug 30, 2015, 3:14:16 PM8/30/15
to Light Table Discussion
Hi !

I believe the default behaviour already has a debounce. You could try overriding with a larger debounce (and throttle if you like) in a user behavior override.
Relevant line in current behavior: https://github.com/LightTable/Clojure/blob/69ab5de10f7b873556cc7f6b17af44e817893053/src/lt/plugins/clojure/instarepl.cljs#L49

However since debounce and trigger aren't params to the behavior as such, I'm not sure you could override in any other way than to turn-off the default behaviour
and add your own;

Maybe like so:
in user.cljs
-------------
(behavior ::my-eval-on-change
          :triggers #{:change}
          :debounce 500
          :throttle 500
          :reaction (fn [this]
                      (let [parent @(:frame @this)]
                        (when (:live parent)
                          (object/raise this :eval true)))))

in user.behaviors
----------------------
[:editor.clojure :-lt.plugins.clojure.instarepl/eval-on-change]
[:editor.clojure :lt.plugins.user/my-eval-on-change]

not tried it, but should work in theory :-)

cheers
Magnus

Camilo Roca

unread,
Sep 23, 2015, 12:39:57 PM9/23/15
to Light Table Discussion
Hey Magnus Thanks for the info !

If I understand this correctly, there is no current way to actually pass parameters to the eval-on-change behaviour, right?

From my point of view, if the user could change this, then bugs like this (https://github.com/LightTable/LightTable/issues/894) or that (https://github.com/LightTable/LightTable/issues/964) wouldnt happen at all :/
Reply all
Reply to author
Forward
0 new messages