Fork me on GitHub
#clojurescript
<
2017-03-10
>
qqq00:03:25

what do you mean? doesn't the cljs compiler do precisely this?

tmayse00:03:06

I want to take user input and make sure it doesn't contain anything malicious like javascript, SQL or other problematic strings

anmonteiro00:03:57

@tmayse goog.string/htmlEscape, maybe?

tbaldridge01:03:04

@tmayse commonly that's done via using transport protocols that aren't weak to such attacks. For SQL that's parameterized queries, for JSON that's using something that escapes properly, ditto for HTML. There isn't really a one-size-fits-all way of sanitizing strings

qqq02:03:45

every time I have a choice between function vs macro -- and I pick macro -- I've come to regret my decision

josh.freckleton04:03:41

I have 200 simple elements updating according to a dispatch every second (as a proof of concept), and on each second it lags. Can re-frame handle this sort of updating, and I just did something inefficiently?

shaun-mahood04:03:20

@josh.freckleton: Can you share example code? I'd be curious to see it, though I don't know that I can help.

tbaldridge04:03:10

@josh.freckleton in these cases it's best to look at what's actually changing, In some pathological cases React will try to destroy all 200 elements and recreate them. A few log statements in your render functions should tell you what's going on.

gklijs07:03:01

@josh.freckleton I had 2000 elements updated every 150 ms and that went fine on most devices, even on a few years old cheap chromebook

urbanslug09:03:24

Hey, you guys know a good way to convert time into a date? Not sure if I should even be doing so or better yet how to comapare time to see one is greater than another

hlolli10:03:12

cljs-time is good, but moment.js is in my opinion really powerful too (can be used from cljsjs/moment)

roman01la12:03:56

what’s the purpose of IndexedSeq type in ClojureScript? Array-like structure and faster conversion between types?

dnolen13:03:48

You need a wrapper type for primitive seq like things

roman01la13:03:04

@dnolen wonder why IndexedSeq doesn’t implement -assoc since it is an indexed collection type?

dnolen13:03:36

it’s a wrapper around primitive/host-y (Array-Like) types

dnolen13:03:16

-assoc isn’t going to work in a generic way for those

dnolen13:03:23

i.e. Array, String, NodeList etc.

roman01la13:03:33

@dnolen does it mean that IndexedSeq is like the most low-level collection type in ClojureScript on top of which everything is built?

dnolen13:03:54

it just means it’s a wrapper around JS Array-Like stuff

dnolen13:03:40

it exists so that you can coerce some JS thing into a value you can use the standard lib on

roman01la13:03:02

oh, I get it now, thanks

roman01la13:03:20

can you explain this? ((fn [& args] (type args)) 1 2 3) ;; cljs.core/IndexedSeq

dnolen13:03:59

prior to transducers, how were you going to map a String or filter an Array or reduce a NodeList?

roman01la13:03:40

agree, that is very useful

dnolen13:03:43

@roman01la an implementation detail, but extra args is often an array (copied from arguments)

roman01la13:03:49

@dnolen makes sense, thanks for clarifying!

dnolen13:03:24

@roman01la to your other question - we don’t use wrappers internally much unless there’s a good reason because there is an overhead to doing that

dnolen13:03:44

many of the persistent collections are implemented on top of JS arrays directly

danielstockton15:03:50

Any recent changes relating to source maps in latest cljs? Mine are not generated anymore.

dnolen15:03:02

@danielstockton not that I’m aware and no one else has reported anything

razum2um16:03:01

I started to like modularity and data-oriented libs.. ^_^ Who can point to any plain-js lib like https://github.com/juxt/bidi to simply get data back, no express-webserver-style like .on(’/’, fn) please

ddellacosta16:03:42

hey folks, running up against a problem importing a google closure lib namespace. I’m trying to use the static method goog.html.testing.newSafeHtmlForTest (https://google.github.io/closure-library/api/goog.html.testing.html) to pass in a value to the setSafeHtml method on a Tooltip (https://google.github.io/closure-library/api/goog.ui.Tooltip.html)

ddellacosta16:03:38

I get a runtime type error when I try to call this static method: TypeError: goog.html.testing is undefined

ddellacosta17:03:04

I’ve tried including it a variety of ways, but nothing seems to work. Do I have to do something else to use this namespace in ClojureScript?

gws17:03:36

@ddellacosta that worked at a cljs repl for me

gws17:03:40

(hi dave!)

ddellacosta17:03:01

cool let me give that a shot. I’ve been using import but haven’t tried require yet, or giving it an alias like that

gws17:03:24

with Closure at least you should be able to use the require semantics you're used to, so no need to alias if you don't want to, you can :refer as well

ddellacosta17:03:55

I have to admit I’m pretty fuzzy on how exactly google closure libraries work in terms of including them

ddellacosta17:03:17

I have the java import model stuck in my brain, and this seems to work differently

ddellacosta17:03:54

nice, that worked—thanks!

ddellacosta17:03:10

huh, also, on a hunch tried one way of using import I hadn’t yet—`[goog.html testing]`

ddellacosta17:03:14

and that also seems to work

ddellacosta17:03:24

not sure why I’d choose one over the other—any idea?

ddellacosta17:03:38

I guess it’s nice to use require exclusively for simplicity’s sake, at least

gws17:03:58

I don't work in cljs enough for it to stick with me either. there's a page on the cljs wiki that links to a blog post that may be of interest https://github.com/clojure/clojurescript/wiki/Dependencies#closure-library

ddellacosta17:03:18

oh, this is the page I always forget about! haha

gws17:03:21

there are times you need to use import with classes and enums

ddellacosta17:03:24

bookmarked, thanks

shaun-mahood17:03:37

@ddellacosta @gws: The up to date docs are for that are at https://clojurescript.org/reference/google-closure-library - I started an issue related to it at https://github.com/clojure/clojurescript-site/issues/60 - I had a lot more difficulty than I expected figuring out how things should work. If you have any thoughts on what would improve the clarity or areas you struggled with, I'm going to attempt a PR at some point to improve things there.

gws17:03:21

awesome, thank you!

ddellacosta17:03:22

@shaun-mahood ah okay, thanks—much appreciated

ddellacosta17:03:15

echoes what Gordon just said but nice to have it all in one place

shaun-mahood17:03:31

@ddellacosta: Not sure how relevant it is to what else you're doing, but I also refer to http://www.spacjer.com/blog/2014/09/12/clojurescript-javascript-interop/ about as often as those pages

ddellacosta17:03:00

@shaun-mahood not relevant to what I’m doing right now, but I forget tons of stuff on this page on a regular basis so I bookmarked it immediately

ddellacosta17:03:20

I wish the official docs were more comprehensive here

ddellacosta17:03:39

anyways, great link, thank you!

shaun-mahood17:03:08

@ddellacosta: Open an issue and I would love to work on improving them over time - as long as you signed your CA you can help!

ddellacosta17:03:30

I’ll think on it 😄

ddellacosta17:03:34

I think I sent in my CA a while back

shaun-mahood18:03:31

Related to the http://clojurescript.org site, is there any plan or timeline to remove info from the wiki and point to the official docs as they are migrated so that people will update their old bookmarks and so forth? Or is it kind of sitting in deprecated limbo until further notice? I'd be happy to help with clean-up and linking if that's at all useful.

dnolen19:03:38

@shaun-mahood I’ve been putting deprecation notices on the big pages that moved over

shaun-mahood19:03:23

@dnolen: Ok, I'll copy that message for any that are missing it - might only be the G Closure one but I'll see what else I can do to help with migrating other pages as well.

dnolen19:03:01

cool could definitely use help here

macroz23:03:39

so binding support in ClojureScript still doesn't work in go-block?

johnnyillinois23:03:44

Can someone help me with my cljs compile linking? Currently, I have an SPA that can be reached at: localhost:3449/things/1/things/2. Routing things/1/things/2 to 'index.html' Unfortunately, the javascript dependencies are referenced with: js/compiled/out/{a.js, b.js, c.js} which the browser tries to fetch: localhost:3449/things/1/things/2/js/compiled/out/{a.js, b.js, c.js}. However, I would like to absolute paths. For example, localhost:3449/js/compiled/out/{a.js, b.js, c.js}

tbaldridge23:03:32

@macroz bindings don't really exist in ClojureScript

macroz23:03:06

I was digging through old code and was disappointed that they don't work and rediscovered this http://dev.clojure.org/display/design/Dynamic+Binding

tbaldridge23:03:55

@darwin from that link "The simple reasoning is: Clojure has threads, but ClojureScript does not." That's not really true

tbaldridge23:03:05

CLJS doesn't have vars, that's why we can't have bindings

darwin23:03:15

@tbaldridge ok, thanks, I will update it. btw. while I have you reading it, look at the FAQ question "Does it work with core.async?” there. Maybe you could shed some light on it

darwin23:03:42

I’m not familiar with deeep details of core.async implementation

darwin23:03:50

unfortunately