Fork me on GitHub
#clojurescript
<
2019-12-08
>
Philipp Siegmantel07:12:29

Hello, I tired it on the figwheel main channel without success, but maybe somebody here can help me. I having Problems using npm dependencies. A full description can be found here https://clojurians.slack.com/archives/CALJ3BFLP/p1575702450049300 I'm thankful for every hint.

Hi17:12:33

how to get result of a JS promise in clojurescript let expression?

lilactown17:12:48

(.then promise
  (fn [value]
    (let ...)))

luizmineo17:12:25

Hi, can someone tell me if clj-refactor on emacs is compatible with shadow-cljs projects?

luizmineo17:12:08

I'm trying to use it with a project generated with the default re-frame template, but no luck so far 😞

thheller18:12:48

@luiz.mineo might be better to ask in #cider but I think it should work just fine when you add the middleware and dependency?

👍 4
luizmineo18:12:02

Thanks, I'll try to ask there

Hi18:12:15

how to get value from javascript promise synchronously? :thinking_face: I am ok to block

thheller18:12:30

@feikas there is no blocking in javascript. not possible.

😢 4
thheller18:12:47

if you were blocking your promise could never complete because there is only one thread.

Hi18:12:46

what if it is already in another thread?

thheller18:12:00

there are no threads ...

thheller18:12:19

you have one single event loop that does all the work

Hi18:12:38

how do I get value then 😕

thheller18:12:14

you .then it. see the response of @lilactown above

Hi19:12:33

actually await does what I need

thheller19:12:16

await turns your entire function async. that might have other implications 😛

thheller19:12:33

its also not supported in CLJS

Hi19:12:59

so hard

thheller19:12:03

thats the life in JS. everything is async so you kinda have to plan around that

awb9919:12:01

I have a problem doe which I am not sure if I can use macros or if I need to use clojurescript analyser. I want to put clojure expressions into clojurescript / reagent apps that will be evaluated via nrepl. (def a 1) (def b 2) (clj (+ a b)) => (clj-eval "(+ 1 2)") (def state (reagent/atom {:a 1 :b 2})) (defn calculator [] [:div (clj (+ (:a @state) (:b @state)))]) Clj-eval I have implemented. What I want is that reagent can detect changes to atoms and then force re evaluation. I am unsure how I have to implement 'clj' function / macro...

thheller19:12:28

you'd need a secondary argument you can use as a trigger

thheller19:12:24

(clj (+ (:a @state) (:b @state)) state) and when you have an update you modify state to trigger it

awb9919:12:41

I am not ywt sure if this is possible at all

awb9919:12:58

The + needs to be unevaluated

thheller19:12:17

sounds weird to me and rather limited in what you can actually eval

awb9919:12:22

The (:a state) needs to be evaluated

thheller19:12:25

also rather unsafe 😛

thheller19:12:33

(clj (System/exit 0))

awb9919:12:46

It is for a notebook

awb9919:12:59

So of course people can do crazy stuff there.

awb9919:12:22

I will not be able to safeguard against that

awb9919:12:32

This is why we host in kubernetes

awb9919:12:47

And pods that atw fucked up get restarted

thheller19:12:37

(clj (loop [] (recur)))

awb9919:12:36

What would be worse

awb9919:12:46

Is id people use the notebook service

awb9919:12:55

To launch dos attacks

awb9919:12:01

Or di email spamming

awb9919:12:05

Or what not

awb9919:12:17

This sort if abuse I am more concerned of

awb9919:12:41

Right now we pray to God that people I clojure community are all nice.

awb9919:12:13

I rhink to implement clj

awb9919:12:18

I just write a macro

awb9919:12:40

That returns a function with 2 parameter (in this case)

awb9919:12:00

Ans then it internally string concats then and xalla rhe cljs-eval