Fork me on GitHub
#clojurescript
<
2015-12-10
>
Chris O’Donnell02:12:47

I'm trying to pull the html for a website into my app with a GET request using cljs-http, but I'm getting these CORS errors No 'Access-Control-Allow-Origin' header is present on the requested resource. I'm not 100% sure if this is because I should be GETing this webpage using cljs.http but am doing it wrong or if I should be grabbing the html in a different way (like through the server). Any input would be much appreciated.

trancehime02:12:24

@codonnell: it means the HTML is located on a different domain than the server you are initiating the request on

Chris O’Donnell02:12:54

Yes, that is intentional. I'm scraping a page from a different website.

trancehime02:12:30

You would need to allow the header on the site where you would like to get your resources from

Chris O’Donnell02:12:03

It is not my website, so I can't do that. I'm scraping because there is no API to use.

trancehime02:12:12

That's a problem.

Chris O’Donnell02:12:32

I can scrape just fine from clojure--just not clojurescript.

Chris O’Donnell02:12:17

So I suppose the solution is to do it on the server, then!

bryce03:12:12

if you’re doing it from the client, you’re using their cached cookies or other credentials, which means that it could make private information available to your script (i.e. gmails, facebook friends, etc.)

mfikes03:12:48

@danielcompton: Descriptions of the implicit macro loading behavior, as well as :include-macros true sugar have made it into (doc ns) in newish REPLs. simple_smile

danielcompton03:12:02

Is it documented anywhere?

clojuregeek04:12:38

I want to pass a url to my clojurescript per environment, like something in the project.clj .... dev has different endpoint than production ... can't find anything so far to help with this in clojurescript.

jimmy04:12:42

Hi guys, I'm learning om next. Checking through this example : https://github.com/omcljs/om/wiki/Components%2C-Identity-%26-Normalization. I have some questions : where is :person/by-name defined, is it defined through :keyfn :name passing as parameter when we create the Person component. Thanks

mfikes04:12:21

I’m willing to take on the issue @dnolen mentioned earlier (https://clojurians.slack.com/archives/clojurescript/p1449702186005954) I wrote a ticket that I believe accurately captures it: http://dev.clojure.org/jira/browse/CLJS-1507

mfikes04:12:07

I suppose the :rename issue can be sorted by someone as well. https://clojurians.slack.com/archives/clojurescript/p1449702009005943 I saw Brandon Bloom makes good use of it to avoid a collision here: https://github.com/brandonbloom/fipp#printer-usage

clojuregeek05:12:41

in case anyone else was wondering about my question earlier ... http://www.martinklepsch.org/posts/parameterizing-clojurescript-builds.html .. does what I want simple_smile

mfikes05:12:15

@nxqd: There's an #om channel

thheller09:12:48

someone with really in-depth node.js knowledge arround? got a few questions about require('vm')?

sveri09:12:30

Hi, am using reagent and notice a difference between passing around a reference to a state atom or directy referencing it. The difference is, by directly referencing it, updates on it work otherwise not. Is this expected? Should'nt it work too if I just pass a reference to the function and use that?

puzzler10:12:20

I have a question for those who have tried using a library like createjs or phaser to build a game in clojurescript, and then using cocoonjs to build it into a mobile app. Does clojurescript's heavy need for garbage collection kill mobile performance, or does mobile perform just fine?

dreic11:12:15

is there something like a newsletter or twitter account that informs about clojurescript developments, news, tutorials etc?

mfikes12:12:34

@dreic Clojure Gazette often covers ClojureScript.

jaen12:12:16

Yeah, that's the closest you'll get to Ruby/Javascript weekly this side of FP divide ; d

jstew12:12:52

@sveri: From the reagent docs:

The easiest way to manage state in Reagent is to use Reagent’s own version of atom. It works exactly like the one in clojure.core, except that it keeps track of every time it is deref’ed. Any component that uses an atom is automagically re-rendered when its value changes.

dreic12:12:02

cool, thanks. Someone should invite Peter Cooper to Closure.

jstew12:12:50

dreic: You could be the next peter cooper! simple_smile

dreic12:12:23

jstew: I have just ordered my first Clojure book simple_smile

sveri12:12:49

@jstew: Thanks, not sure how I missed that, given the fact I already implemented it several times^^

dreic12:12:57

My reach into Clojure has not been beyond lists.

jstew12:12:08

sveri: I forget about it all the time. It's bitten me a few times.

jaen12:12:07

@sveri: I think it doesn't update because you do not dereference the atom inside this function. You should be able to pass atoms as arguments in general.

sveri12:12:48

@jaen: I think I did it correct, the problem was, like jstew said, that I used a cljs atom instead of ratom^^

sveri12:12:00

Thanks to you both for helping me simple_smile

jaen12:12:54

Ah, right. That's a vexing bug when you mistmatch the atoms ; d

sveri12:12:27

Indeed, especially as everything was working until I refactored my functions to take the state as a parameter instead of directly referencing it

sveri12:12:26

Hm, is there a way to combine a prismatic schema definition with reagents ratom? It seems like schema does not recognize the ratom as a map if I red that error message correctly

sveri12:12:57

It seems like ratom is a deftype

angusiguess13:12:01

What does your annotation look like?

sveri14:12:36

@angusiguess: thx, I look at it

sveri14:12:45

That worked, thank you very much

gabe15:12:14

getting a few errors when updating 1.7.145 -> 1.7.170

gabe15:12:50

are there known issues along this path?

gabe15:12:17

they’re all from goog util.js, base.js and run.js

gabe15:12:47

Uncaught TypeError: Cannot read property 'WEBKIT' of undefined

gabe15:12:58

goog.require could not find: goog.testing.watchers

gabe15:12:11

Uncaught TypeError: goog.uri.utils.phishingProtection_ is not a function

gabe15:12:19

the last is caused by the first i think

snowell15:12:21

Anybody know if there’s a functional/technical difference between using an anonymous function for the :on-click of a component versus defining a function outside of the component and using partial for :on-click?

gabe15:12:23

@snowell: as long as the function returned from the call to partial has proper arity, it shouldn’t matter

gabe15:12:43

i do it a lot in my code

snowell15:12:10

Is that better/worse than just defining an anonymous function, as far as performance?

gabe15:12:05

i would guess the performance/code sharing trade-off would be negligible.

gabe15:12:42

i would worry more about introducing bugs w/ duplicate code

snowell15:12:20

Fair enough

gabe15:12:17

getting the same issues going 1.7.145 -> 1.7.166

dnolen15:12:03

@snowell: performance for click handlers really doesn’t matter simple_smile

dnolen15:12:29

@gabe: doesn’t sound like anything ClojureScript related at all

dnolen15:12:41

I would examine lein deps :tree for Google Closure library conflicts

gabe15:12:44

@dnolen: i’ll try that

gabe15:12:21

lein deps is giving me a lot of suggestions that i’ll have to try out

gabe16:12:51

@dnolen: it looks like goog.userAgent is being called before it’s defined

dnolen16:12:14

@gabe: nobody has reported anything like this before

dnolen16:12:25

you should assume environment issues long before anything else

dnolen16:12:04

everything about that error points to Google Closure Library dependency issue

dnolen16:12:40

also make sure you done the basics - clean the build, delete target directory, etc.

gabe16:12:45

think it was an issue w/ a cleaning the build. had an old version of utils.js hanging around

gabe16:12:20

have to remember to do this on lib upgrades.

isak17:12:02

can anyone recommend a good lib for tracing in clojurescript?

naomarik19:12:26

(if-let [[_ value] (find st key)] is the "_" common idiom for a destructured variable we don't care about?

jaen19:12:10

Yep, _ is frequently used as a wildcard pattern in functional languages. Fortunately Clojure went along with that instead of something odd like *. I remember seeing that in some language and being surprised as to what it meant.

julia19:12:37

yeah _ is pretty widely used as 'whatever else'

johannjohann21:12:13

does anyone have any experience reports for using the compile time typechecking mentioned here? https://github.com/clojure/clojurescript/wiki/Compile-Time-Type-Checking

aav22:12:49

@jaen i think, ‘_’ as a wildcard was first used in Prolog

dnolen22:12:30

@johannjohann: it’s an experimental thing, not finished - somebody will need to wrap up what I started

johannjohann22:12:17

@dnolen: best place where i can read up on what needs to be done?

dnolen22:12:17

@johannjohann: Google Closure Compiler error logging needs to be source mapped, then somebody needs to kick the tires with it to determine what works and what doesn’t.

jaen22:12:52

@aav: that's quite possible; Prolog's old enough to be it. From what I can google about ISWIM and SASL they didn't seem to have a wildcard pattern and ML's younger than Prolog.

anisoptera22:12:50

Does anyone have a link to some good examples of how to do interop between native iOS objects/functions and Om/React/ClJs?

anisoptera22:12:32

Everything I've found is out of date or assumes I'm just trying to write my entire app in cljs. Which would be cool but I need to touch core data at some point

artemyarulin22:12:41

There is a dedicated channel #C0E1SN0NM for mobile development, many folks are there already

anisoptera22:12:05

Oh cool thanks :)

tom22:12:41

Is anyone aware of a cljs project (looked at prismatic/dommy) that will take a string of HTML and help let me select elements from the HTML string?

tom22:12:16

I think that'll do, thanks!

puppybits22:12:50

Is there a was to pass in different variables in the project.clj file? I was to inject a dev security token when dev but nothing when it’s compiled for production.

isak23:12:47

@puppybits if this is for clojure, you can specify different

:resource-paths
in the different profiles and then:
(load-file (.getFile (resource "config.clj")))
, for example

puppybits23:12:13

this is with clojurescript with figwheel and cljsbuild

isak23:12:49

i don't know of anything that would work out of the box, but worst case, you could script the builds from clojure

puppybits23:12:41

ok. i’ll try that. I was hoping cljsbuild had something built in. But I wasn’t finding anything.

pandeiro23:12:06

@cfleming: I asked a pretty unreasonable question there on your HN thread; but to me that would be the cljs IDE experience I would want, as a frontend dev

cfleming23:12:07

@pandeiro: That didn’t seem like a very unreasonable question to me.

pandeiro23:12:54

@cfleming: We have JS (not CLJS) tooling in Emacs that can do that...

cfleming23:12:04

Right now there’s nothing like that, although I’d like to add it. I’m actually planning to run a REPL over the debug connection at some point, which might provide better information.

cfleming23:12:14

@pandeiro: Interesting, got a link?

cfleming23:12:19

Interesting, it doesn’t talk about completion there at all.

pandeiro23:12:33

Yeah, that is the engine for emacs<->browser communications

cfleming23:12:38

Is it something like Figwheel?

pandeiro23:12:45

The actual AC I'm googling for, been a while since I used it

pandeiro23:12:04

I was using it when I was doing AngularJS dev and it worked pretty well

pandeiro23:12:29

But I imagine bridging the JS-CLJS gap is not trivial...

cfleming23:12:56

It sounds like that uses js2 mode for completion (i.e. static like Cursive), and Skewer for evaluating

cfleming23:12:10

Or does it also use Skewer for completion?

pandeiro23:12:26

I think it uses Skewer to get the global browser env

pandeiro23:12:41

I may be wrong about that, given the example there, but I remember when using it that there was a ton of network communication going on...

pandeiro23:12:02

hence why I thought it was somehow grabbing the global (i.e. js/window) env

pandeiro23:12:37

yep, it was, wasn't it?

cfleming23:12:15

Yeah, looks like it gets the global object and builds from there.

cfleming23:12:45

Cursive does something similar for Clojure, but even there I’m thinking about dialing it back because it’s problematic (i.e. mostly slow).

cfleming23:12:59

Lots and lots of network traffic, like you say.

pandeiro23:12:49

@cfleming: IMO, but not being very familiar with IntelliJ/cursive, the major value proposition from cursive is mostly derived from the fact that it is JVM native

pandeiro23:12:24

and in that sense, I wonder, if the best CLJS/browser dev experience would be something integrated into Chrome DevTools itself

cfleming23:12:53

Perhaps, certainly Cursive has a lot it can take advantage of for JVM Clojure

rantingbob23:12:14

As a beginner, the main value prop is that its much easier to setup than the other options, and I don't have to learn emacs.

cfleming23:12:14

But the web dev tooling in IntelliJ/WebStorm etc is pretty amazing too.

pandeiro23:12:43

Yeah sure, Emacs is emacs @rantingbob simple_smile

pandeiro23:12:59

@cfleming: Yeah I also don't know Webstorm well at all

mfikes23:12:06

Hey @cfleming I’m working on an update to ClojureScript’s ns form and it occurs to me that it might affect Cursive with respect to symbol resolution.

cfleming23:12:28

@mfikes: Sure, what’s the change?

cfleming23:12:09

I actually need to update the CLJS resolution for some cases that don’t work right now, like implicit :require-macros

mfikes23:12:48

@cfleming: I can write a Cursive ticket for it if you think it does indeed affect Cursive.

cfleming23:12:15

@mfikes: You could add a comment to https://github.com/cursive-ide/cursive/issues/775 perhaps, which I’m planning to fix soon.

cfleming23:12:50

I did try to fix that at one point, but the double indirection was tricky to index IIRC.