Clojurians
#clojurescript
<
2017-01-13
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

tbaldridge02:01:53

@selfname in clj IWithMeta is just IMeta. IMeta in CLJ is IObj.

igrishaev06:01:32

hello, does anybody have experience writing cljs tests with phantom.js? when I try to call page's method evaluate I get strange error.

(deftest test-home
  (let [page (-> "webpage" js/require .create)]
    (-> page
        (.open ""
               (fn [status]
                 (.evaluate page
                            (fn [] (is (= 1 1)))))))))
Testing foo.core-test

Ran 1 tests containing 0 assertions.
0 failures, 0 errors.
ReferenceError: Can't find variable: jq

  undefined:1
  :1

sova07:01:01

Hrm, why is it looking for jayq?

igrishaev07:01:28

@sova that does not mean jQuery, I used to get other 2-letters names, hg, cf etc

iconara09:01:54

I can't get my custom clojure.spec generators to work in ClojureScript, could anyone tell me what I'm doing wrong? Here's a minimal example in the Figwheel repl:

iconara09:01:03

user=> (require '[clojure.spec :as s] 'clojure.test.check.generators '[cljs.spec.impl.gen :as gen])
nil
user=> (gen/sample (s/gen (s/with-gen string? (gen/string-alphanumeric)))))
#object[TypeError TypeError: self__.gfn.call is not a function]
(stack trace deep into minimized code)
nil

iconara09:01:44

using gen/sample with something that doesn't have a custom generator works fine:

iconara09:01:48

user=> (gen/sample (s/gen string?))
("" "h" "yP" "D" "" "Yev4" "dc" "zgc38" "GUZgb" "CM")

gfredericks10:01:31

@iconara what if you replace (gen/string-alphanumeric) with either gen/string-alphanumeric or (constantly gen/string-alphanumeric)?

leov12:01:41

if I will use only PATCH requests with cljs-ajax, can I disable ring-csrf-protection?

iconara12:01:20

@gfredericks yes, it worked, but it leads to a new problem:

iconara12:01:21

(gen/sample (s/gen (s/with-gen string? (gen/such-that #(not= "" %) (gen/string-alphanumeric))))))

iconara12:01:43

fails with the same error as before

iconara12:01:53

and

(gen/sample (s/gen (s/with-gen string? (gen/such-that #(not= "" %) gen/string-alphanumeric)))))

iconara12:01:03

fails because the second argument to with-gen must be a generator

gfredericks12:01:40

I thought it's supposed to be a 0-arg function that returns a generator

gfredericks12:01:00

that's what the docstring in jvmland says at least

iconara12:01:48

hm, that might be the key

iconara12:01:58

(gen/sample (s/gen (s/with-gen string? (fn [] (gen/such-that #(not= "" %) gen/string-alphanumeric))))))

iconara12:01:00

seems to work

iconara12:01:17

(this is not how my code looks, I'm just trying to use a minimal example here)

iconara12:01:15

@gfredericks thanks for the help, I think your 0-arg hint was what was missing

lsenta13:01:34

What's the correct way to use a javascript library that requires other libraries? ala https://github.com/pouchdb/upsert/blob/master/dist/pouchdb.upsert.js

lsenta13:01:11

Should I import each library using foreign libs? Or is there something more straightforward?

smee13:01:57

Question: Is the keyword (keyword "/") valid? I ask because in clojure (read-string ":/") works fine, but (cljs.reader/read-string ":/") fails with the error message "Cannot read property '0' of null"

smee13:01:40

Usecase is a serialization of function names and their documentation meta data. Since / is the divide function, it gets serialized as :/

mitchelkuijpers14:01:36

@hlolli That looks awesome thank you for the tip, I was looking for something like this

smee14:01:19

Nevermind, found it: Clojurescript follows the EDN spec, which states Per the symbol rules above, :confused: and :/anything are not legal keywords.

borkdude15:01:22

Is it possible to record a profile in Chrome programmatically? e.g. when a request finishes, then start and when a certain function finished stop?

borkdude15:01:26

@hlolli looks similar to sass/less?

andres-alonso15:01:14

Is it possible to build a re-frame app without React to drop into an existing react app

andres-alonso15:01:01

So that I can build a component in CLJS without including React twice?

selfsame15:01:34

@borkdude yeah

if (window.console && window.console.profile) {
     console.profile("label for profile");
     // insert code to profile here,
     // all function calls will be profiled
     console.profileEnd();
   }

borkdude15:01:48

@selfsame Awesome, thanks!

hlolli15:01:02

@borkdude @mitchelkuijpers yes looks very similar to sass. Since it's closure library I wonder if it compiles without needing any external library with clojurescript. Worth investigating further....

mitchelkuijpers15:01:39

Especially the renaming stuff would be very cool

mitchelkuijpers15:01:11

Seems like something that integrates really nice with clojurescript

hlolli15:01:40

they also seem to include some constants and functions that one would need to download and include specifically in scss, well, better try before promising it too much :slightly_smiling_face:

borkdude15:01:01

garden is also very nice, you can just use clojure functions

hlolli15:01:27

yes, never got into garden yet, tried it few times.

mitchelkuijpers15:01:01

I use om-css with garden so that you have css with your components, works pretty nice actually

selfsame15:01:05

yeah co-locating css does wonders

rauh17:01:55

@borkdude If you want something similar to stylotron:

stuartsierra21:01:08

I'm getting is not a function errors with :optimizations :advanced. The missing function seems to be ReactDOM.findDOMNode. I have dependencies on [cljs-react-material-ui "0.2.35"] and [org.omcljs/om "1.0.0-alpha47" :exclusions [cljsjs/react cljsjs/react-dom]] Can anyone else confirm?

darwin21:01:43

missing externs, maybe?

stuartsierra22:01:00

I did that and the error was ReactDOM.$findDOMNode$ is not a function.

bhauman22:01:20

@stuartsierra a react lib conflict for sure

stuartsierra22:01:21

I can add an :externs file to fix it, but I'm trying to understand the root of the problem.

stuartsierra22:01:28

Currently working on a small example case.

bhauman22:01:02

first find out what version of react you are actually using via lein deps :tree

bhauman22:01:53

maybe externs after all

stuartsierra22:01:47

I've got the React that's bundled with cljs-react-material-ui

darwin22:01:27

I would simply (aget js/window “ReactDOM” “findDOMNode”) or something similar, depends if this is just a single case or some systemic externs problem

dnolen22:01:57

findDOMNode isn’t a thing anymore far as I can tell

stuartsierra22:01:42

OK, interesting, but it works with an :externs declaration.

stuartsierra22:01:24

I notice that cljs-react-material-ui bundles react.ext.js but not react-dom.ext.js

dnolen22:01:59

@stuartsierra ah, k makes sense as seems consistent with the post

dnolen22:01:30

not bundling the DOM externs seems like a problem

dnolen22:01:08

(I missed the bit React.findDOMNode -> ReactDOM.findDOMNode)

stuartsierra22:01:47

Sorry, that was cljsjs/material-ui, not cljs-react-material-ui