Fork me on GitHub

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


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


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!


hi, I'm trying to use 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.


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


does anyone have an example of remote streaming with clojurescript?


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


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


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


the first thing i tried was just returning a stream


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


so yeah i think i need or something


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


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


@tomaas maybe externs inference can help you identify the problem


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


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?


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.


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


thanks @U8ES68TGX I'll check that out


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


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?


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?


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


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?


It can take an externs kv as well, I believe


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


good point. i’ll open an issue.


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


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


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


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

❤️ 4

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


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


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


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


js->clj wasn't happy with that


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


there’s still not enough information here


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


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


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


since it’s a problem for any consumer


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


and use Transit instead


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


any strangeness is probably the result of ignorance not intention


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


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


one could also copy&paste js->clj implementation and make keyfn optionally specified by the caller, e.g. doing there read-string or whatever,


yeah read-string works


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.


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


so the cache is keyed on this representation


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


You'd probably have to use server side


nice. i'll give that a try.


thank you.


I am using fspec on a CLJS app

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

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


I am also using expound.


Is this due to how fspec is being instrumentated?


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


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


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


However, if I remove fspec it takes about 1s


There is this issue Is your load time issue occurring with :advanced, or is just a dev-time thing?


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


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


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


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


Is fspec used at runtime by default?


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


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