Fork me on GitHub
#nbb
<
2022-08-18
>
Steffen Glückselig12:08:41

I am looking for @(promise) but for nbb, i.e. I have a script that should not finish. Concretely I have a script that waits on changes to the clipboard, executing actions on its content, that should never finish on it's own. How would I do that in nbb? In bb I'd add @(promise) at the end of the script...

borkdude12:08:23

@steffenglueckselig I don't know what the idiomatic node solution is but something like this might work:

$ nbb -e '(defn wait [] (js/Promise. (fn [resolve reject] (js/setTimeout #(do (resolve) (wait) 10000000))))) (wait)'
What it does: every 10000 seconds it resolves a promise but starts waiting for a new one...

🙏 1
lispyclouds12:08:39

Maybe (nbb.core/await (js/Promise. #())) does it too?

🙏 1
lispyclouds12:08:49

directly translating await new Promise(() => {});

lispyclouds12:08:22

doesnt seem to work with nbb -e '(nbb.core/await (js/Promise. #()))' but works in the repl

Steffen Glückselig12:08:52

It does work in a script, though. Thanks!