Fork me on GitHub
#clojurescript
<
2016-03-13
>
anmonteiro00:03:48

@amacdougall: I think you won't have that problem if you setPathPrefix in goog.Html5History

anmonteiro00:03:01

I cant remember if it should be set to "/" or "", but one of them solved this problem before

bwstearns00:03:52

I can't tell which side client/server my problem is originating, but when trying to get json from my server the value is saved as a string of the response. Anyone have a suggestion as to where to look first? I'm using cljs-ajax. The request looks like (GET "/titles" {:handler pieces-handler :format :json})The raw response from the server looks like {:id 2, :title "foo"}{:id 4, :title "bar"}.

vmarcinko09:03:34

@bronsa: are there any plans to include tools.analyzer in clojurescript, or you think it is very unlikely?

toxi14:03:00

hiya... has anyone ever run into the compiler producing the ns dependency order? i'm having a ns with only constants and made sure it's :required from everywhere needed. the ns shows up in the final .js file, but only much later after where it's needed first. tried to build a smaller example to reproduce, but w/o success. is there a way to dump out the dependency graph built by the cljs compiler?

toxi14:03:49

...producing the wrong ns dependency order...

bronsa14:03:21

@vmarcinko: highly unlikely -- tools.analyzer.js is now really out of date with the current cljs version and I don't really have time anymore to update it. And even if somebody were to do that work, integrating t.a with cljs is really not my call, but @dnolen's

base69816:03:21

I'm trying to iterate over a sorted-set set with loop. i'm getting the xs with rest and it's returning a list. I need it to stay a sorted-set

chrisoakman16:03:00

@base698: is there a specific reason you're using loop?

base69816:03:30

i could probably do it in some kind of reduce. it's just handling events sequentially

base69816:03:48

could probably use map

base69816:03:17

event more concise: (map do-event events) though do-even can return another even, is there like a map until done?

chrisoakman16:03:30

I'm not 100% certain this is what's happening in your case, but generally when you iterate over collections they are turned into sequences, which are represented as lists internally.

base69816:03:45

yeah that's probably what it is

chrisoakman16:03:10

Are you just interested in the side-effect of applying a function to every element in your set?

base69816:03:11

keep-map or something if that was a method would be what i needed

chrisoakman16:03:35

Or are you trying to convert from "data structure A" to "data structure B"?

base69816:03:56

I have events that get processed and sometimes turn into other events.

base69816:03:21

wonder if keep returns a list or set

base69816:03:08

damn, still list

chrisoakman16:03:47

seems like you have two things happening: 1) you want something to happen with every item in your set 2) you want to keep your set a set. Is that accurate?

base69816:03:28

(apply sorted-set (keep do-event events)) ;; seems flaky

chrisoakman16:03:21

I would recommend using doseq to "run" your do-event function

chrisoakman16:03:02

if do-event needs to "change" your set, then I would separate that "change" into a reduce

chrisoakman16:03:04

does that make sense?

kingoftheknoll18:03:41

I’m building an sdk browser library that I want other to be able to consume with JS, but I don’t always want to convert js->clj and clj->js on the api. So my current thought is using something like David Nolen’s Mori library to surface an api for cljs datastructures. But I want to avoid having basically two copies of cljs on the browser. Wondering if I can require Mori and forward the API’s through my library thus only compiling one copy of the underlying clojurescript.

chrisoakman19:03:48

@kingoftheknoll: not really sure you can get around this problem like you described

chrisoakman19:03:48

What is the JS API that you are exposing? Would it be natural for a JS developer to pass Objects / Arrays to it?

kingoftheknoll19:03:48

It would be a CLJS api that I’m exposing, that is a wrapper around a REST api. The product I’m working on allows for plugin type extensibility. I am going to be using the base CLJS library for more CLJS layers on top of it. Like a Reagent app, etc. This part is just the data layer

kingoftheknoll19:03:46

So a plugin developer could tie into my sdk and build their own pages on mount points I surface to them. And they could use the same data layer that I use for our internal stuff.

kingoftheknoll19:03:23

So I’m incentivized to keep the date structures cljs.

chrisoakman19:03:58

So that's the "cljs consumed" case, right? And there is a separate, "js consumed" case?

kingoftheknoll19:03:48

yup, so if someone loads some js code to say run an angular app on a div tag I provide, they may want to get a preprocessed version of “group info” func that does some transforms and coorelates data from several api endpoints. It would return a PersistentHashMap. It would be a bit weird similar to how using ImmutableJS vs literals is weird but they could get all the benefits of clojure and I don’t have to convert at the interface.

kingoftheknoll19:03:53

Only other options in my mind are surfacing clj->js and js->clj function and/or adding a flag to those functions specifying what format they want

chrisoakman19:03:13

If I were a JS developer writing an Angular app, I'm not sure I would want to have to deal with PersistentHashMap 😉

kingoftheknoll19:03:26

😃 no doubt. oh if only “extensible everything” wasn’t such a big requirement with our platform.

chrisoakman19:03:52

This is probably more of an API design question than a CLJS question.

chrisoakman19:03:41

What I would do: export JS functions that take and return JS Objects and Arrays

chrisoakman19:03:28

And make them be in camelCase, all that jazz. Make them look like they were written in JS.

chrisoakman19:03:44

I would probably use goog.exportSymbol

chrisoakman19:03:57

and just have them mirror the CLJS functions

kingoftheknoll19:03:15

that’s a good idea, thanks!

amacdougall20:03:37

Here's a conundrum for you, not specifically ClojureScript, but it's something most CLJS webapp devs will confront... let's say I have a single-page app which uses client-side routing. The server-side is set up to interpret <domain>/path/to/app/* by rendering the app template; anything beyond the wildcard, such as /path/to/app/entries/10, is handled by the client-side routing. So far, so good. So what if /entries/10 does not exist? If the client side has to load the CLJS app, then make an API request, then report the results in an error page, that means we return 200 from the original request long before we realize that it's really a 404. I see two obvious possibilities: I could interpret the route on the server side first, and return a 404 if I have reason to believe the client side would not be able to render it. This involves a fair bit of extra work, and essentially duplicates the routing table. Or I could just... not worry about it. Which is fine for this hobby app, but offends my sensibilities.

grav21:03:24

With isomorphic/universal apps, I think you’d do what you suggest, eg return a 404 from the server. In this case the front and backend share the routing table.

juhoteperi23:03:43

Package cljsjs/react{,-dom,-dom-server,-with-addons} versions {0.14.{4,5,6,7},15.0.0-rc.1}-0 are now available in Clojars!

juhoteperi23:03:00

React 15 should be mostly non-breaking change for wrappers which work with 0.14 and one interesting change is that it should finally support all SVG tags and attributes: https://facebook.github.io/react/blog/2016/03/07/react-v15-rc1.html

bpicolo23:03:41

how do people typically use react with cljs other than Om?

bpicolo23:03:34

Now i'm doubting my decision to om

bpicolo23:03:23

;_; frontend always did move too fast

bpicolo23:03:21

those make state management look a bunch easier

juhoteperi23:03:54

Yes, frontend moves fast but both Om and Reagent have been around since December 2013 😄

bpicolo23:03:13

@juhoteperi: what sort do you prefer?

juhoteperi23:03:10

@bpicolo: Re-frame readme is the best documentation even for pure Reagent

juhoteperi23:03:22

@bpicolo: I prefer Reagent.

bpicolo23:03:02

might have to try it, I'm not so far in : P

cky23:03:01

@bpicolo: For the record, I love Reagent+re-frame.