Fork me on GitHub
#nbb
<
2023-03-07
>
jaide13:03:54

Given a script like below, how would one expose the promesa.core alias p to make it accessible within the repl?

(ns demo.core
  (:require 
   [nbb.repl :as repl]
   [promesa.core :as p]))

(defn -main []
  (p/do! (repl/repl) (println “Repl closed”)))

borkdude13:03:56

I guess we could support an :init expression

borkdude13:03:24

- :init, function of no arguments, initialization hook called with
       bindings for set!-able vars in place.
       default: #()

borkdude13:03:29

similar to clojure.main/repl

borkdude13:03:47

but then something that returns a promise, probably, to enable require stuff

jaide13:03:03

That would be great. Updating and upgrading the replit nbb template, thought it would be nice if one could immediately write (p/-> (js/fetch “”) (.text) (println))

borkdude13:03:25

issue and/or PR welcome

jaide13:03:26

Will create the issue right now. Got a few questions about the impl then can give it a shot later in the afternoon

borkdude09:03:19

Published as 1.2.171. The PR with the version bump didn't trigger the publish since it also needs a tag. Next time it would be better if I did that myself and not as part of a PR but thanks for the attempt :)

jaide19:03:38

My mistake! Didn’t mean to overstep there.