Fork me on GitHub
#clojurescript
<
2017-05-18
>
john00:05:20

zipf was the word I was looking for. https://en.wikipedia.org/wiki/Zipf%27s_law You get a zipf distribution on all projects on github to build your dictionary.

john01:05:18

the first base64 char can refer to the top 60 or so top programming words, with some of the last chars reserved to extend the table.

iku00088803:05:18

Are there any tips against :advanced optimization removing one of your side effectful steps?

iku00088803:05:05

More specifically, this snippet seems to be completely removed:

iku00088803:05:26

(aset (.getElementById js/document "some-id-string")
        "innerText" value) 

iku00088803:05:59

(the 'value' being a function parameter)

iku00088803:05:39

In simple mode it compiles to

document.getElementById("some-id-string").innerText=a 

iku00088803:05:55

But in advanced mode it gets removed...

iku00088803:05:04

Using goog.dom.setTextContent instead worked + make it live through :advanced

iku00088803:05:07

Yay, I guess. Always look into closure library first...

john04:05:14

I usually see set! used

john04:05:22

Does that not work with your case, with innerText?

iku00088804:05:36

lemme check...

iku00088804:05:52

Would the parameters be same?

john04:05:01

(set! (.-innerText (.getElementById js/document ...

john04:05:46

(set! (.-innerText (.getElementById js/document "some-element")) "something")

john04:05:03

Not sure if that'll fix your sitch though

iku00088804:05:37

Yeah, still seems to be removed even with set!

iku00088804:05:13

But a function in goog.dom works so I can live on, thanks again!

grounded_sage11:05:48

Is there a library for figuring out critical CSS? Not sure how it would work. Booting up PhantomJS or something?

tomaas12:05:11

Hi, has anyone trie :input-type :password with re-com input-text component? I don't see the input box at all when using that?

grounded_sage13:05:38

dvingo: thanks these will be good to look at. I am using Garden and doing it both as a stylesheet using Clojure and also having it match up in my client side rum components.

aperson12:05:27

Fela only adds styles to the markup that have actively been rendered. Unused style declarations are left out by default.

aperson12:05:40

not sure if that also includes libs outside the component's css

aperson12:05:56

didn't know about this one, thanks @thheller !

grounded_sage13:05:21

Most seem to use PhantomJS under the hood.

cmal13:05:24

Hi, how can I send a request using cljs-ajax with Content-Type of application:x-www-form-urlencoded? I've tried to set the :header but it failed. It seems the content-type should be set in the :format field but it seems I need to write a :write function and I do not know how to write the :write function. Thanks!

negaduck13:05:17

hello. Question about secretary/dispatch!. I have (re-frame/reg-event-db ... [... (re-frame/after go-home)] ...) and (defn go-home [_] (println "hello") (secretary/dispatch! "/"))). The function gets called, prints hello, [:set-active-panel home-panel] gets sent, but the url in address bar doesn’t get changed. Shouldn’t secretary/dispatch! do this? Btw, I use pushy for urls without octothorp

cmal14:05:15

@negaduck I tried to write the :format field like this:

:format {:content-type "application/x-www-form-urlencoded"
        :write .toString}
but the browser gives me a 400 bad request xhrio.js:620 POST 400 (Bad Request). And this exception happens at the function this.xhr_.send(). Does this mean my request not been send correctly?

negaduck14:05:30

@cmal, hm, :3449 looks like figwheel’s port

cmal14:05:07

Yes. I am trying to add a proxy in figwheel's http server and try to access to a remote URL. I am debug in the figwheel-sidecar project, but it seems the server does not receive the request. I think the request was not send correctly.

negaduck14:05:28

@cmal, what about (POST "/send-form-modern" {:body (js/FormData. form-element)})? Or (POST "/send-form-modern" {:content-type ...})?

negaduck14:05:41

without :format

cmal14:05:22

ahh.. I use re-frame, it force to use ajax-request format

cmal15:05:31

@negaduck the GET/POST form works. Thank you!

negaduck15:05:27

for the record, I found that if I use pushy, I have to use pushy/set-token! instead of secretary/dispatch!

giovaferra16:05:21

Hi everyone! I'm still here, thanks for the patience. I decided to write my clojurescript, async test manually, setting each symbol's value to a new value, storing the old value with a new symbol. After test I would go back with old symbol and old value. I thought to use "use-fixture" as specified here "https://clojurescript.org/tools/testing" but if I store the old values in symbols defined in the ":before" function how can I get them in the ":after" function??

metametadata17:05:43

@giovaferra I doubt it's possible unless you create some global registry var which is visible in both functions. As alternative to fixture you can create a helper function and use in every test explicitly.

metametadata17:05:09

also consider rewriting the code under test so that you can directly inject the dependency which you try to stub/mock

john22:05:35

With something like this: (defn do-apply [x] (apply (first x) (rest x))), when I do (do-apply '(+ 1 2 3 4)) complains with Error: Invalid arity: 5 whereas (do-apply [+ 1 2 3 4]) works. Why does it appear to be unquote splicing?

anmonteiro22:05:50

@john you’re trying to apply arguments to a symbol, not a function

anmonteiro22:05:22

cljs.user=> '(+ 1 2 3)
(+ 1 2 3)
cljs.user=> [+ 1 2 3]
[#object[Function "function (a){for(var b=[],c=arguments.length,d=0;;)if(d<c)b.push(arguments[d]),d+=1;else break;switch(b.length){case 0:return cljs.core._PLUS_.cljs$core$IFn$_invoke$arity$0();case 1:return cljs.core._PLUS_.cljs$core$IFn$_invoke$arity$1(arguments[0]);case 2:return cljs.core._PLUS_.cljs$core$IFn$_invoke$arity$2(arguments[0],arguments[1]);default:return b=new cljs.core.IndexedSeq(b.slice(2),0,null),cljs.core._PLUS_.cljs$core$IFn$_invoke$arity$variadic(arguments[0],arguments[1],b)}}"]
 1
 2
 3]

john22:05:34

I'd like to be able to take a clojure source form and execute it in non-self-hosted mode, when the compiled artifacts of that form are already available in the target environment. So, I'm supposing I need to walk the form, expand all the names to fully namespaced names, macroexpand where necessary, etc. Is that possible or not?

john22:05:35

perhaps using .apply or .call?

john22:05:28

so, rather than compiling, something that just interprets/translates CLJS forms into callable js, when the compiled functions are already available.

qqq23:05:31

in cljc files, is there a way to require a macro without using #?(:cljs ... :clj .... ) ?

john23:05:40

but hmm, perhaps I can't assume that cljs.core._PLUS_ is available in the target environment?

qqq23:05:43

I just want a unified way to require macros

john23:05:52

Yeah, I guess in :advanced mode there's no way to map arbitrary forms down to their minified counterparts in the target env, at runtime.