Fork me on GitHub
#clojurescript
<
2018-09-19
>
its.ramzi01:09:09

Really my goal is to implement column dragging of tables

its.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?

its.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?

its.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

idiomancy02:09:17

thanks @mfikes

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

alexmiller03:09:14

what about an unbuffered core.async channel?

alexmiller03:09:26

sounds like you basically want a rendezvous

alexmiller03: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 🙂

alexmiller03: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 [] [email protected])))))

(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 [] [email protected])))))

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

puremonad14: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")

jesse.wertheim14:09:54

@puremonad you mean like goog.object/get?

jesse.wertheim14: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.

puremonad14:09:25

wow thanks 🙂

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

jarvinenemil18: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