Fork me on GitHub
#clojurescript
<
2017-05-21
>
bobcalco02:05:45

How does one unload a node module in ClojureScript? It boils down to: How do I call:

delete require.cache[name];
Where name is the fully resolved path to the module I want to unload.

bobcalco02:05:04

I got the (aget node/require "cache" name) part working. But neigher (node/delete …) nor (js/delete ...) work.

anmonteiro02:05:37

@bobcalco I don’t know any way to do it other than:

(js* "delete ~{}" (goog.object/get js/require.cache name))

anmonteiro02:05:17

oh actually, there’s js-delete

anmonteiro02:05:27

(js-delete js/require.cache name) should work

bobcalco02:05:49

both seem to do the trick

bobcalco02:05:00

Thanks also for the reference @anmonteiro !

danielstockton07:05:04

What is the cljs way of creating ES6 classes?

danielstockton07:05:41

e.g. class Something extends React.component {

danielstockton07:05:05

My understanding is that it isn't possible.

thheller07:05:32

totally possible but slightly different to implement

thheller07:05:01

also not ES6 classes but the end result is the same

thheller07:05:12

can’t find the minimal example I made before

thheller07:05:28

that contains the basics

thheller08:05:12

create a constructor function like component-fn, call (js/React.Component.call this ...)

thheller08:05:43

then (gobj/extend ...) the rest is specific to my framework thingy

thheller08:05:31

not the target audience, but maybe you folks will like it. https://www.youtube.com/watch?v=BLDX5Twt2zk

jimmy09:05:54

thheller: Nice work

binora16:05:04

this is great!

lilactown20:05:56

that's awesome but the video is giving me epilepsy 😵

qqq09:05:41

I'm aware of :source-map-timestamp

qqq09:05:53

is there an option to tell cljs to attach timestamps for generated *.js files too ?

qqq09:05:59

somehow, my reload is reloading old files

misha12:05:35

greetings! starting from how many, say, conjes it will make sense to wrap vector in transient? (let's say in a web or mobile app context) 10? 1000?

misha13:05:48

(let [f #(->> % (reduce conj []))
      t #(->> % (reduce conj! (transient [])) (persistent!))
      L 10
      v (vec (range L))]
  (time (dotimes [_ 1000] (f v)))
  (time (dotimes [_ 1000] (t v))))

"Elapsed time: 2.158171 msecs"
"Elapsed time: 1.594682 msecs"
      L 20
"Elapsed time: 9.934248 msecs"
"Elapsed time: 3.654435 msecs"
      L 30
"Elapsed time: 16.031698 msecs"
"Elapsed time: 3.905617 msecs"
      L 40
"Elapsed time: 15.380363 msecs"
"Elapsed time: 2.552671 msecs"
      L 50
"Elapsed time: 26.149719 msecs"
"Elapsed time: 8.002839 msecs"

dnolen12:05:14

@U051HUZLD I’m not sure I understand the question really. I wouldn’t use transient unless benchmarking showed some benefit.

misha12:05:32

I thought there might be some basic rule of thumb, similar to "don't use datomic, if you will need 100b datoms within a year". My use case is in a function, which will deal with seqs of varying size of ~1-100. Was wondering if it even matters at such sizes (given, say few years old android device as an execution env,)

lxsameer20:05:27

hey guys, is there anything like requirejs for clojurescript ?

cpmcdaniel22:05:43

oh, I think I found my answer