Fork me on GitHub
#clojurescript
<
2018-09-19
>
Ramzi01:09:09

Really my goal is to implement column dragging of tables

Ramzi01:09:34

Should I not be messing with an HTML table at all, and I should just be modifying the order of the data?

Ramzi01:09:30

Specter is difficult to import.

idiomancy02:09:44

@its.ramzi specter is difficult to import?

idiomancy02:09:04

Hey, does anyone know if there's an equivelant of delay without the caching behavior?

Ramzi02:09:56

i downloaded specter from github and there were java, cljc, and clj files. i didnt know where to put the java files

idiomancy02:09:37

err, sorry, I might not be understanding you correctly. all you need to do is specify it as a dependency in your project.clj:

:dependencies [...
                 [com.rpl/specter "1.1.1"]
                 ...]

mfikes02:09:13

@idiomancy I'm not aware of a non-caching delay, but I suspect you could make your own fairly easily

(defn non-caching-delay [f]
  (reify IDeref
   (-deref [_] (f))))
Since this is not a macro, you'd have to pass a thunk as in
(def my-non-caching-delay (non-caching-delay (fn [] ,,,)))

mfikes02:09:20

You could go farther and make a macro that builds the thunk for you, just like the delay macro does.

mfikes02:09:47

From the bigger picture, it seems like you could just define a function and call it. All the above really buys you is the ability to use deref.

idiomancy02:09:05

which I might do any way just for job security

mfikes02:09:54

Interesting problem. I suppose you have a large value you don't want to hold onto in a delay or a value that otherwise can become stale.

idiomancy02:09:28

essentially. yeah

Alex Miller (Clojure team)03:09:14

what about an unbuffered core.async channel?

Alex Miller (Clojure team)03:09:26

sounds like you basically want a rendezvous

Alex Miller (Clojure team)03:09:46

java.util.concurrent.SynchronousQueue accomplishes the same (if you want interop and no dep)

mfikes03:09:31

This is that other dialect, hosted on another platform 🙂

Alex Miller (Clojure team)03:09:42

oh crap, didn’t realize what channel I was in :)

mfikes03:09:23

Heh. I once asked for a napkin when in London. Same language, but different semantics.

idiomancy03:09:26

alright, I'll bite. What does napkin mean in UK english?

mfikes03:09:28

Essentially the same as the sanitary variant in US English.

idiomancy03:09:16

I'll be keeping this line in my back pocket

idiomancy03:09:32

well, since we're all here, does anyone want to help me polish this macro off?

(defmacro derefable [& body]
  `(reify IDeref (-deref [~(gensym)] ((fn [] ~@body)))))

(derefable "hello")
=>
----  Compiler Warning on   <cljs form>   line:1  column:1  ----

  Bad method signature in protocol implementation, clojure.lang.IDeref does not declare method called -deref

  1  (derefable "hello")
     ^--- 

----  Compiler Warning  ----

mfikes03:09:04

@idiomancy You just need to qualify a couple of things:

(defmacro derefable [& body]
  `(reify cljs.core/IDeref (cljs.core/-deref [~(gensym)] ((fn [] ~@body)))))

mfikes03:09:42

I think it is OK (but not sure if idiomatic) to use _# in lieu of ~(gensym) there.

idiomancy03:09:14

oh cool, I was wondering that exact thing

mfikes03:09:38

You'll also see it if you do (source simple-benchmark) for unused binding name in dotimes

idiomancy03:09:35

nice. _# it is, then

LazyMonad14:09:42

hello, maybe someone could help me 😉 is there some alternative to aget? for e.x. (aget (aget (first (aget data "results")) "name") "first")

jaawerth14:09:54

@puremonad you mean like goog.object/get?

jaawerth14:09:42

you can also do property access (for valid identifiers) with the (. obj -prop) or (.-prop obj) syntaxes

john14:09:12

Yeah, (-> data .-result first .-name .-first) might do it.

LazyMonad14:09:25

wow thanks 🙂

👍 8
lilactown18:09:43

@puremonad do note that property access is NOT the same as aget. property access will get munged in advanced compilation unless you have externs defined for the object you are accessing

lilactown18:09:10

it's a tricky thing because it will work in development and then potentially fail in production if you're not careful

dangercoder18:09:26

Do you guys know any good read on CLJS and deployment?

pesterhazy19:09:12

Compile into a bundle. Upload to S3. Put it behind a CDN

dnolen19:09:39

@coderdanger we really don’t do anything novel here - same best practices as JavaScript

ghiden20:09:22

anyone using cljs with vue?

orestis07:09:12

I had a brief look but I couldn’t find anything useful there. What’s your use case for Vue + CLJS? In my findings, I couldn’t find anything in Vue that transported over to CLJS.

orestis07:09:00

The Vue template language gets directly translated to JS, so you can’t hook CLJS in there. The Vue “instances” rely on proxies etc so they won’t work with CLJS data structures. There is no custom event system like React has so no extra value there. In the end, you’d be using Vue only for the VDom implementation, which I haven’t compared to others yet.

ghiden08:09:57

so just thought that there might be some people doing vue + cljs