nbb

Steffen Glückselig 2022-08-18T12:04:41.693939Z

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...

borkdude 2022-08-18T12:13:23.089479Z

@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
lispyclouds 2022-08-18T12:18:39.912159Z

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

🙏 1
lispyclouds 2022-08-18T12:19:49.230739Z

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

lispyclouds 2022-08-18T12:23:22.613909Z

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

Steffen Glückselig 2022-08-18T12:56:52.184859Z

It does work in a script, though. Thanks!

lispyclouds 2022-08-18T12:57:33.033439Z

nice! 😄