Fork me on GitHub
#clojurescript
<
2018-02-05
>
fabrao02:02:30

Hello all, what is the use of async and await of javascript?

fabrao03:02:10

in clojurescript?

justinlee03:02:23

the closest analogs in my opinion are go blocks (`async`) and <! (`await`) from core.async

levitanong03:02:57

@fabrao Dunno about await but async has something to do with doing tests on asynchronous things.

justinlee04:02:08

@levitanong I think he’s asking about javascript’s async/await keywords, which are closest to go blocks

levitanong04:02:49

Oops, silly me!

Ryan Radomski06:02:31

Is pr-string data structures a good way to serialize edn or is there something more space efficient?

noisesmith18:02:29

pr-str would be the standard way to make edn - edn is a string format and doesn’t allow space optimizations. There’s transit which is designed to store arbitrary clojure data, and is extensible, and optimized for avoiding duplication of shared data in the output, but it’s not edn. It is faster than edn though, and has libraries to consume and create the data from other langauges.

jrbrodie7706:02:25

For any Cursive + cljs users out there. The REPL that I end up with by running a lein figwheeel task is pretty lame, up/down arrows do not search history so I end up copying and pasting all the time. Should it be better?

joelsanchez08:02:37

I start a regular clj repl from cursive and call "cljs-repl" from the figwheel api

joelsanchez08:02:44

works flawlessly

kurt-o-sys09:02:55

I'm trying to use existing npm packages inside my cljs project. I can make the example from https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/ with left-pad work. However, when I try another package (`apollo-client`), it doesn't work:

nenadalm19:02:53

Hi. You can see discussion here: https://github.com/macchiato-framework/macchiato-core/issues/23 on how to use npm deps in cljs.

kurt-o-sys09:02:58

I did add the npm package to :npm-deps (just the way I added left-pad).

kurt-o-sys09:02:18

I seem to be able to load the apollo-client, but I can't do anything with it:

(require '[apollo-client])
nil
cljs.user> apollo-client
#object[ReferenceError ReferenceError: [...]$node_modules$apollo_client$index is not defined]
nil
cljs.user> apollo-client.
#object[ReferenceError ReferenceError: apollo_client_SLASH_ is not defined]
nil
cljs.user> apollo-client/ApolloClient
#object[ReferenceError ReferenceError: [...]$node_modules$apollo_client$index is not defined]
nil
How can I use apollo-client?

kurt-o-sys09:02:31

checking the apollo-client module source: it has this structure:

-- packages
   |
   |- ...
   -- apollo-client
so it has a package apollo-client (amongst others).

kurt-o-sys09:02:10

And packages/apollo-client/rollup.config.js:

import build from '../../rollup.config';

export default build('apollo.core');
I'm not sure how to deal with this 😛.

kurt-o-sys09:02:00

^^ how can I make the apollo-client run in cljs?

dnolen09:02:38

@kurt-o-sys I think if you just want to be productive A) just build your JS separately and use a single include B) try an alternative tool like shadow-cljs

dnolen09:02:40

:npm-deps is for the long haul, there’s still a lot of work to do, and not just us (Closure Compiler)

kurt-o-sys09:02:10

oh, ok... so it's better to avoid :npm-deps for now?

dnolen09:02:14

or for the adventurous with some time to spare to help push it forward 🙂

dnolen09:02:33

if your goal is to just get something done - yes avoid it

dnolen09:02:49

:npm-deps works OK for some simple things and stuff like just React

kurt-o-sys09:02:21

yeah, that's my goal 🙂 . OK, let me see how shadow-cljs works. thx.

tomaas11:02:50

hi, im trying to use lein-asset-minifier to minize the compiled reagent app's app.js file and I get this error: JSC_READ_ERROR. Cannot read: /home/user/sample/target/cljsbuild/public/app.js at (unknown source) line (unknown line) : (unknown column)

dpsutton20:02:42

can you use this as an argument in cljs? does it get munged away from this in the emitted code?

joelsanchez20:02:09

yes you can, I use that name when I pass this explicitly

dpsutton20:02:33

but in that situation a collision would be undetectable? if it was the this argument or the keyword this in javascript?

joelsanchez20:02:42

"this" is nothing in cljs

joelsanchez20:02:49

you need to use this-as for accessing it

joelsanchez20:02:57

or use (js* "this")

dpsutton20:02:02

ah ok. so there are steps to prevent the collisison

dpsutton20:02:36

(defn stuff [this]
  (+ 3 this))

;; becomes 
letfn_bug.core.stuff =
(function letfn_bug$core$stuff(this$){return ((3) + this$);});

dpsutton20:02:01

thanks for the help