Fork me on GitHub
#clojurescript
<
2016-10-27
>
Alex Miller (Clojure team)00:10:10

If you want that you have to invoke tools.reader yourself

denik03:10:00

@noprompt could it be that the latest clojurescript version breaks garden css?

denik03:10:56

@noprompt it breaks with [org.clojure/clojurescript "1.9.293”]

mfikes03:10:38

@jrheard core.logic is not compatible with self-hosted ClojureScript. (FWIW, work has been done recently for core.match: http://blog.klipse.tech/clojure/2016/10/25/core-match.html)

sivakumargsk06:10:04

I was trying to integrate my cljs-project with quickbooks api. should any one done please give me a suggestions?

Pablo Fernandez07:10:10

Are there any downsides on using cookies for auth for an API only service?

deas08:10:14

@darwin For the record, I think anything but using <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> is really asking for trouble. May be worth emphasizing it in the docs.

naomarik11:10:26

@pupeno i don’t see why not, this is how every rails application does authentication by default. the session information is encrypted and stored as a cookie in the client. checkout https://funcool.github.io/buddy-auth/latest/#signed-jwt

naomarik11:10:59

and a few SMS endpoint services i’ve used just simply have some small token they put in the URL or headers that identify your app

Pablo Fernandez11:10:59

@naomarik isn’t jwt an alternative to using the session and thus, cookies?

naomarik11:10:29

@pupeno from my understanding sessions use cookies to track user state. i haven’t implemented anything in clojure quite yet but at least in rails this is how it works

naomarik11:10:48

all i need to login as someone else is their cookie for that domain that includes all the session info

Pablo Fernandez11:10:59

@naomarik yes, that’s how it works. jwt uses a non-cookie token to track users.

niwinz11:10:18

in any case, cookies can be used as the token transport header

niwinz11:10:46

there are no problem with mix jwt for generate tokens and cookie as transport header

naomarik11:10:11

yes this example i sent seems to just include the token in the authorization headers.. i don’t see why you wouldn’t be able to put it in a cookie though and be able to sign/unsign the data

niwinz11:10:00

the advantage to setting it on cookie is that in browser you don't need to hadle that headers manually 😛

deas11:10:03

@darwin In fact, it seems even worse than that. OOTB tomcat (need it) serves HTML setting ISO-8859-1 encoding header. And that even supercedes the meta header in the document.

naomarik11:10:52

also you can set expiration stuff and expire tokens by changing your secret key

naomarik11:10:08

https://github.com/funcool/buddy-auth/blob/master/examples/session/src/authexample/web.clj this example here seems closest to what i’m saying but i feel like it’s storing everything as plaintext, not sure how that info is being saved on the client

naomarik11:10:08

okay https://github.com/ring-clojure/ring/wiki/Sessions#session-stores the session middleware allows you to put your key there

naomarik11:10:27

so the data you put on the client is not visible

naomarik11:10:02

just have to use the ring.middleware.session.cookie/cookie-store

darwin12:10:25

@deas at least you know where the problem is… 🙂

deas12:10:49

@darwin I may have missed something, but I think it may really be worth mentioning so other people don't run into similar issues.

darwin12:10:29

well, people don’t read docs, so we would have to fix that “problem” first 😉

darwin12:10:35

I think better time investment would be to check popular project templates and make sure meta charset it present there

deas12:10:53

@darwin Exactly what I was about to say!

deas12:10:41

@darwin ... and ring serving HTML using utf-8 response headers as well. People may be crazy enough run uberwars on tomcat.

noprompt14:10:37

@denik I discovered that last night. I've been working hard at trying to fix a number problems. It's been difficult.

octahedrion16:10:24

is there a way to get some code prepended to the start of a generated js file from clojurescript ? I want to add the importScripts() line for webworkers

octahedrion16:10:57

i mean, i could post-process the generated js files, but i was wondering if there's a hack or feature in clojurescript

verma16:10:15

I think there used to be a :preamble option afair

flyboarder16:10:47

Hey everyone, quick question, with the new 1.9.293 are we still not able to do :refer :all would it be better to do use?

anmonteiro16:10:47

@flyboarder: :refer :all isn't supported and may not ever be. use must be used with :only so you have to list everything you want to refer to anyway

derpocious17:10:45

Hey guys I am pretty new to ClojureScript, and I am really amazed by figwheel!

teslanick17:10:41

Are there any React wrappers for CLJS that support the context feature? I’ve looked at a bunch, but I didn’t see anything super-obvious.

thheller19:10:00

@teslanick not aware of anything but I have done it manually and it isn't fun 😛

gowder19:10:24

has anyone out there tried to use the closure library for matrix math? I can't even figure out how to initialize a matrix. The API docs say that it's a class ( https://google.github.io/closure-library/api/goog.math.Matrix.html ), the actual code looks like a function ( https://github.com/google/closure-library/blob/master/closure/goog/math/matrix.js#L57 ) and regardless of how I call it, I get a type error. Viz:

(require '[goog.math :as math])

(.log js/console (math/Matrix (clj->js [[1 2 3][4 5 6]])))

;; type error: goog.math.Matrix is not a function

(.log js/console (math/Matrix. (clj->js [[1 2 3][4 5 6]])))

;; type error: goog.math.Matrix is not a constructor

(.log js/console (new math/Matrix (clj->js [[1 2 3][4 5 6]])))

;; ditto, not a constructor

well, then, what in blue blazes is it, if it isn't a constructor or a function?

thheller19:10:59

@gowder goog.math is not goog.math.Matrix

thheller20:10:06

(require 'goog.math.Matrix)

thheller20:10:28

(js/goog.math.Matrix. (clj->js [[1 2 3][4 5 6]])) should do it

gowder20:10:34

ooh. that simple, eh. hah. thanks

teslanick20:10:55

Uff. That’s annoying. It seems like the cljs wrappers [for React] out there a lot ‘thicker’ than I want. 😕

gowder20:10:35

@thheller also, so the name of the library is also a constructor?! that's... wow.

thheller20:10:09

well technically the goog.math.Matrix is used to find the FILE that contains the source

thheller20:10:19

which is goog/math/matrix.js or something

thheller20:10:30

that then defines the goog.math.Matrix object

thheller20:10:41

only then do you get the constructor

thheller20:10:58

if you require goog.math it loads goog/math.js which has no knowledge of Matrix

gowder20:10:17

but then how do things like :as and :refer work?

gowder20:10:30

I guess maybe they don't, because it's not real clojurescript?

thheller20:10:32

analyzer magic 😉

thheller20:10:54

in your case you could do

thheller20:10:13

(:import [goog.math Matrix]) and then (Matrix. ...) if you don't like the js bit

thheller20:10:33

refer of classes is funky

gowder20:10:07

hmm. definitely not as clean as the jvm. thanks!

Emma20:10:00

Hi. I'am trying to solve this, rather tricky problem with Reagent. However, it looks like an architectural problem in React based apps. Correct me if I'am wrong. We have a map component. That would be a parent component in Reagent

var mymap = L.map('mapid').setView([51.505, -0.09], 13);
We build up a Reagent component using life cycle methods. Then, we have a lot of subcomponents, like popups and shapes that bind to a parent like this
var marker = L.marker([51.5, -0.09]).addTo(mymap);
If we build each of them as a reagent component then how do we add them to our map? React renders children first. So, every :component-did-mount on children will not work(because parent hasn't been initialized yet) We can try to work around passing "yet to be rendered" atom down to children, then subscribe to it and wait for parent's component-did-mount call. But it looks hackish to me. Any ideas how to simplify this?

thheller20:10:08

answer basically is to use componentWillMount

thheller20:10:38

but the official answer is do not build stuff like that via components but in your state instead

Emma20:10:28

@thheller ComponentWillMount will work before rendering. So we can't initialize map on '#mapid' (it doesn't exist yet). Having a

mymap
in a state is kind of a hack nonetheless. (We can't compose/recycle it without additional code). Or I don't understand something?

Emma20:10:28

@thheller I am using state approach right now. It works, but, I am looking for better ways. Thanks

thheller20:10:57

dunno do the children that try to add things to the map have to be react components?

thheller20:10:30

otherwise a component that just create a div with a react ref

thheller20:10:51

should be enough to get a div into the page and then generate the map instance on it

thheller20:10:43

dunno but be careful with componentWillMount as componentWillUnmount is the wrong order again 😛

Emma20:10:51

Well, if we need them to auto update/remove themselves based on the state I guess.

wielderofmjolnir21:10:10

Hi! I'm having some issues with compiling my project with :optimizations set to anything. Is this a suitable channel to ask in? 🙂

wielderofmjolnir21:10:52

Great! My build is, and has been, working fine all day. But just now I decided to try compiling using :optimizations :advanced, and Google Closure throws the error: >Oct 27, 2016 11:36:12 PM com.google.javascript.jscomp.LoggerErrorManager println >SEVERE: $HOME/flask-cljs/flask_cljs/target/cljsbuild-compiler-1/flask_cljs/core.js:6: >ERROR - required "flask_cljs.core.components.sidebar" namespace never provided >goog.require('flask_cljs.core.components.sidebar'); And the same for the only other file in the "components" folder, and thus the ns flask-cljs.core.components. My only dependecy is reagent. Also, compiling with any :optimizations, even :whitespace, throws the same error, aaaand I'm quite new to Clojure and Clojurescript 😊

anmonteiro21:10:23

@wielderofmjolnir hrm so your project is named flask-cljs right?

anmonteiro21:10:38

what's your folder called?

wielderofmjolnir21:10:08

Supposed to have underscores for the filenames and hyphens for ns, yeah?

anmonteiro21:10:13

that's right

anmonteiro21:10:40

can you paste the NS form of one of those files that are erroring out?

wielderofmjolnir21:10:06

>(ns flask-cljs.core.components.sidebar > (:require [flask-cljs.state :refer [app-state]]))

anmonteiro21:10:50

hrm looks right to me as well

anmonteiro21:10:18

your project folders are also structured according to the NS structure right?

anmonteiro21:10:29

i.e. you have flask_cljs/core/components/sidebar.cljs

wielderofmjolnir21:10:56

>{:id "min" > :source-paths ["src"] > :compiler {:output-to "../resources/public/js/compiled/flask_cljs.js" > :main flask-cljs.core > :optimizations :advanced > :pretty-print false}}]}

wielderofmjolnir21:10:30

(it's supposed to output to parent-dir, which has been working fine without optimization)

anmonteiro21:10:56

you can probably remove the ../ and have the same effect

wielderofmjolnir21:10:12

Yeah, just tried it and got the same error..

anmonteiro21:10:23

@wielderofmjolnir hrm one last hunch, do you have a flask-cljs.core.components namespace?

wielderofmjolnir21:10:20

Hah, I actually don't!

anmonteiro21:10:54

the problem would be if you had one which declared a sidebar var

wielderofmjolnir21:10:14

Aww.. I got excited there for a second 😄

anmonteiro21:10:52

hrm, one thing though, is that your output-to seems to differ from the path of the error

wielderofmjolnir22:10:31

I figured the target folder was a temporary folder or something.

anmonteiro22:10:05

try specifying a concrete output-dir

wielderofmjolnir22:10:13

Also, I was def wrong earlier. :whitespace of course works.

wielderofmjolnir22:10:45

Different folder though

wielderofmjolnir22:10:18

>flask-cljs/flask_cljs/../resources/public/js/compiled/out2/flask_cljs/core.js

anmonteiro22:10:36

can't say more without having a look at the project

anmonteiro22:10:56

also heading to bed. Probably something about those namespaces, but could be a compiler edge case

wielderofmjolnir22:10:19

I'm trying to merge them all into core.cljs and see what I get then

wielderofmjolnir22:10:45

Thanks though! Really grateful for your help @anmonteiro 😊

wielderofmjolnir22:10:02

Though it's not a very good solution..