Fork me on GitHub
#clojurescript
<
2018-04-18
>
arun.parthiban01:04:00

Do people here have recommendations for some good, upto date sources to learn clojurescript?

soulflyer01:04:22

Not completely up to date, but you can get a long way by reading "Clojurescript up and running" and maybe "Web development with Clojure" for the principles, then study the intro guides to various libraries. (re-frame springs first to mind, but there are lots). If there is a better/easier way I would like to know about it too....

bozhidar06:04:31

A quick note for any CIDER or piggieback users here: * CIDER’s master just dropped support for piggieback 0.2, so if you see some odd errors on start-up you need to update to piggieback 0.3 * piggieback 0.3 was new coordinates - it used to be cemerick/piggieback, now it’s cider/piggieback. Also - it used to live on Maven Central, now it lives on Clojars * piggieback 0.3 doesn’t support rhino anymore - just use the much better Nashorn instead Sorry about any inconvenience this update might cause, but I promise you this is a one time deal!

tomaas07:04:55

hi, I'm trying to use http://idangero.us/swiper lib. Having function Swiper() {} in externs.js file is enough to create the instance of js object of Swiper, but I can't figure out how to declare .slideNext method of that instance.

Roman Liutikov07:04:54

If Swiper is a class, then Swiper.prototype.slideNext = function(){}

Desmond07:04:10

does anyone have an example of remote streaming with clojurescript?

gklijs07:04:16

What do you mean with remote streaming, consuming a stream from a websocket or something? Or producing click events or something?

Desmond16:04:04

both. in this case i have a stream of user inputs that i want to send to a remote function and process the response

Desmond16:04:06

i control the function on the server and right now it is just req/res but i want to change it to take a stream and return a stream

Desmond16:04:50

the first thing i tried was just returning a stream

Desmond16:04:38

and using ajax/POST exactly like before. in that case the correct response is visible in the developer console but the handler gets called with nil

Desmond16:04:55

so yeah i think i need http://socket.io or something

Desmond16:04:35

i'm new to this so i'm just trying to get the diffs between streaming and req/res

gklijs19:04:54

You have multiple options, I like working with a web socket and have a clojure backend.

Roman Liutikov08:04:43

@tomaas maybe externs inference can help you identify the problem https://clojurescript.org/guides/externs#externs-inference

miikka12:04:23

If I have a JS object literal like #js {"foo" "bar"}, Closure advanced compilation can rename foo, right?

diego.videco15:04:18

Hey all, does anyone know about a good tutorial for working with npm modules, and/or wrapping an npm library for use in multiple projects?

diego.videco15:04:23

I was trying to wrap a lib called data.task, but I could not get it to work properly, in the figwheel repl, I could require it, but it gave me an instance of module (like if it was calling new Task on require, but the module actually exports a constructor that has some methods associated with it, like .of and .resolved). In the file I could not even require it, it either returned an error (because of the dot in the module name) or it returned nil if I quoted the module name.

diego.videco15:04:30

I was using npm-deps, but If there a better or more reliable way? What's the story with npm and cljs?

justinlee15:04:40

@diego.vid.eco the npm-deps feature is alpha and in my experience pretty tricky to use. i think what you are asking is how to use an npm module from cljs, right? the two approaches that seem to work reliably are (1) use webpack to bundle up your javascript before you use it or (2) use shadow-cljs and just require npm modules directly. https://gist.github.com/jmlsf/f41b46c43a31224f46a41b361356f04d

diego.videco16:04:38

thanks @U8ES68TGX I'll check that out

lilactown16:04:04

^ +1 for shadow-cljs. it’s a very effective build tool

lilactown16:04:20

question: are there any examples of a library or framework that allows you to bundle a data query (a la Om.Next, Apollo, Relay, etc.) with a reagent component?

jmckitrick17:04:37

I’m documenting an old cljs on node project, and I could have sworn I had cider jumping to definition and a repl running. Does anyone recall how to do this?

jmckitrick17:04:08

The repl seems to be running ok, but the jump-to-definition integration does not work.

justinlee17:04:37

Where is the behavior of the deps.cljs file documented? I see it mentioned by example on the website but I can’t find a reference for how it works. Is the name deps.cljs hardcoded? Can it contain anything other than a :foreign-libs key?

john17:04:13

It can take an externs kv as well, I believe

john17:04:30

I'd like to see some docs on that as well

justinlee17:04:37

good point. i’ll open an issue.

john17:04:16

👍 I'll help resolve it if we can track down the details

john17:04:00

I've found a few places where deps.cljs is used, when I was looking into it the other day

john17:04:07

Cool. I'll do some research this evening

Geoff Glenister18:04:25

I'm trying to set up an event that will look into the reagent db to figure out another event it needs to call, based on what else is going on in the ui. So, for example, the db would have something like :my-event ::request-stuff. In the first event, if I do the following:

{:dispatch [::request-stuff]}
Everything is cool and works right (`::request-stuff` is in the same area of code as the first event that calls it, by the way). But if I set up a let statement with a variable "my-event" getting what's in the db (and I've verified that it pulls back "::request-stuff" as its value), and call:
{:dispatch [my-event]}
My dev console will then tell me re-frame: no :event handler registered for: ::request-stuff. Is this because I need a more explicit way of calling ::request-stuff?

Ivan Fedorov19:04:37

Is there a tldr guide to using es6 module with react dep in a reagent/re-frame project? Thanks in advance

justinlee20:04:53

Use shadow-cljs. There’s a gist I posted earlier in chat for more details. On phone right now tho

❤️ 4
Desmond19:04:33

what is an elegant way to turn {"[3, 2]":{"value":5}} into {[3,2]: {value: 5}}?

dnolen20:04:06

@captaingrover I’m assuming you’re asking about how to go from JSON to EDN

Desmond20:04:17

yes, and my actual response looks like data:{"[3, 2]":{"value":5}}

Desmond20:04:06

which i'm handling in a clumsy way at the moment

Desmond20:04:15

js->clj wasn't happy with that

Desmond20:04:34

so now i'm splitting off the end, using .parse js/JSON and then js-clj but i still wind up with the strings for keys

dnolen20:04:19

there’s still not enough information here

dnolen20:04:28

why are you encoding non-string keys on the JSON side?

dnolen20:04:09

everything resolves around this decision which I would argue is probably not a good idea

dnolen20:04:31

if you want non-string keys they why bother with JSON

dnolen20:04:36

since it’s a problem for any consumer

Desmond20:04:42

you mean why do i want [3,2] as a key?

dnolen20:04:45

and use Transit instead

Desmond20:04:42

i would like to use Transit. The server is Java/Spring and i'm not aware of a way to do that

Desmond20:04:29

any strangeness is probably the result of ignorance not intention

john20:04:00

@captaingrover you can use cljs.reader/read-string on that "[3, 2]" value to get it read in as a vector

john20:04:46

But to david's point, doing so is probably just putting a bandaid on a problem that is not yet fixed somewhere else.

darwin20:04:41

one could also copy&paste js->clj implementation and make keyfn optionally specified by the caller, e.g. doing there read-string or whatever, https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L10566

Desmond20:04:34

yeah read-string works

john20:04:38

The user might want "value" to be "value" sometimes and :value other times, while also dealing with "[3, 2]" correctly. Not enough information in the example to know, but it sounds hairy.

Desmond20:04:18

user is inputing "3,2" or "3&2" and i am caching calculations that would apply to any representation of [3,2]

Desmond20:04:33

so the cache is keyed on this representation

john20:04:43

Yeah, you can handle this stuff manually with read-string, but if you end up building a system of any decent size - with lots of different API endpoints and datatypes moving back and forth - you'll probably want to grab for something like transit

john20:04:57

You'd probably have to use https://github.com/cognitect/transit-java server side

Desmond03:04:46

nice. i'll give that a try.

Desmond03:04:53

thank you.

athomasoriginal20:04:42

I am using fspec on a CLJS app

(s/def ::on-submit (s/fspec :args (s/cat :event map?)))

(s/fdef some-component
  :args
  (s/cat :props (s/keys :req-un [::on-submit]))
  :ret vector?)
using fspec seems to increase load time by 12 seconds

athomasoriginal20:04:16

I am also using expound.

athomasoriginal20:04:25

Is this due to how fspec is being instrumentated?

mfikes20:04:46

@tkjone What do you mean by "load time"?

athomasoriginal20:04:16

I have a table on the front end. it only has about 15 rows, and 6 columns per row

athomasoriginal20:04:32

When I try to access this page, it take 15 seconds for the table to load

athomasoriginal20:04:49

However, if I remove fspec it takes about 1s

mfikes21:04:57

There is this issue https://dev.clojure.org/jira/browse/CLJS-1701 Is your load time issue occurring with :advanced, or is just a dev-time thing?

dnolen21:04:29

@tkjone something to consider, yes spec could be made faster, but also maybe you don’t need it on UI components at runtime

dnolen21:04:40

FWIW, in my own experience using it as a kind of type system doesn’t consistently pay its way

dnolen21:04:56

using it to spec client/server interactions leads to much more win

dnolen21:04:13

any place where it might be a bottleneck - you probably shouldn’t be using it

athomasoriginal21:04:11

Is fspec used at runtime by default?

athomasoriginal21:04:13

I thought you would have to configure it to do so.

athomasoriginal21:04:07

In my case I was using it for annotation more than run time validation