Clojurians
#lumo
<
2017-08-15
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

sjol05:08:45

is it possible to use lumo to build binaries from Clojure programs? If so how?

pesterhazy22:08:33

Top-level await is coming to the chrome dev tools: https://twitter.com/umaar/status/897408737694109697

pesterhazy22:08:44

Something like that for lumo would be awesome

anmonteiro22:08:10

@pesterhazy what do you mean

anmonteiro22:08:16

probably very easy to do with a macro

pesterhazy22:08:30

I think it requires support from the repl infrastructure

pesterhazy22:08:13

essentially this feature makes the prompt block until the (async) response comes back

pesterhazy22:08:01

as far as I understand it at least?

pesterhazy22:08:18

I mean this works today

(async () => `Homepage: ${(await fetch(location.href)).status}`)().then(console.log)

anmonteiro22:08:23

blocking will need extra support

anmonteiro22:08:28

otherwise it can be achieved

pesterhazy22:08:45

i'm curious how they handle a promise that never fires...

anmonteiro22:08:05

like:

(defn x []
  (js/Promise. (fn [resolve reject] (resolve 42))))

(js* "(async () => ~{}(await ~{}))();" js/console.log (x))

anmonteiro22:08:57

^ can easily turn that into an await macro

anmonteiro22:08:11

that you call like (await js/console.log (x))

anmonteiro22:08:41

still not sync

pesterhazy22:08:01

what if lumo detected a promise as a return value and (optionally) awaited its result

pesterhazy22:08:13

for example, (await ...) could be a repl-special

pesterhazy22:08:58

that'd be amazing for experimenting with async apis which, honestly, is most apis in node

pesterhazy22:08:39

so (await (x)) would block until ^C or a promise resolution

pesterhazy22:08:54

(await) would be accepted only as a top level form

pesterhazy22:08:03

I guess similar to (require)?

anmonteiro23:08:23

@pesterhazy feel free to open an issue

anmonteiro23:08:45

that’d probably require some tinkering and refactoring

anmonteiro23:08:48

but sounds like a good idea