Fork me on GitHub
#clojurescript
<
2017-10-22
>
johnjelinek02:10:38

I think I should be more specific about the source: world.js:

require('chromedriver')
var seleniumWebdriver = require('selenium-webdriver');
var {defineSupportCode} = require('cucumber');

function CustomWorld() {
  this.driver = new seleniumWebdriver.Builder()
    .forBrowser('chrome')
    .build();
}

defineSupportCode(function({setWorldConstructor}) {
  setWorldConstructor(CustomWorld)
})
what would that be in cljs?

johnjelinek02:10:17

it seems like the destructured setWorldConstructor might be a big challenging to recreate in cljs

johnjelinek03:10:40

here's what I have so far:

(js/require "chromedriver")
(def seleniumWebdriver (js/require "selenium-webdriver"))
(def defineSupportCode (.-defineSupportCode (js/require "cucumber")))

(defn custom-world []
  (this-as this
    (let [builder (new (.-Builder seleniumWebdriver))
          forBrowser (.forBrowser builder "chrome")]
      (set! (.-driver this) (.build forBrowser)))))

johnjelinek03:10:36

I tried:

(defineSupportCode (#(% (% custom-world)) (.-setWorldConstructor (js/require "cucumber"))))
but ended up with:
Cannot set property 'World' of undefined
in this case, setWorldConstructor is a function in cucumber that modified this.options.World

johnjelinek03:10:58

I feel like this is also pretty close:

(defineSupportCode #((.-setWorldConstructor cucumber)))

Cannot set property 'World' of undefined

johnjelinek04:10:26

I also tried something like this:

(defineSupportCode
  (fn [ref]
    (let [setWorldConstructor (.-setWorldConstructor ref)]
      (setWorldConstructor custom-world))))
same error though

johnjelinek04:10:26

I'm thinking maybe I need to use this-as here too somewhere

johnjelinek04:10:30

not sure where to inject it though

johnjelinek04:10:42

I think ☝️ is equivalent to this:

(defineSupportCode
  #(% ((.-setWorldConstructor %) custom-world)))

johnjelinek04:10:03

same error still

cmal02:10:56

Hi, how to use nth-child pseudo-class in garden? I found it need a extra n parameter but don't know how to write it after :&:. I tried :&:nth-child(4) and :&:(nth-child 4), both failed.

eggsyntax13:10:42

What’s garden?

mfikes14:10:58

@ajs cljs.core/*assert* is really for self-hosted ClojureScript. In JVM-based ClojureScript, clojure.core/*assert* is used during compilation. In other words, if you macroexpand assert, in JVM ClojureScript, you are using clojure.core/*assert*, while in self-hosted, you are using cljs.core/*assert*. A consequence is that if you print *assert* you are simply seeing the value of cljs.core/*assert*. A little more elaboration on the self-hosted aspects of *assert* are at http://blog.fikesfarm.com/posts/2016-05-08-bootstrap-asserts.html

ajs19:10:59

Thanks Mike. I was mainly interested in which *assert* to look at when writing a macro that should have different behavior when :elide-asserts is true. It became clear how to proceed after a bit of playing.

deg14:10:39

What is the correct way in CLJS to implement .then and .catch methods of a JS Promise object? I have code like the following which seems to work perfectly, but triggers a warning in my builds:

(defn sign-out []
  (-> (js/firebase.auth)
      (.signOut)
      (.catch (core/default-error-handler))))
WARNING - Keywords and reserved words are not allowed as unquoted property names in older versions
of JavaScript. If you are targeting newer versions of JavaScript, set the appropriate language_in option.
return firebase.auth().signOut().catch(com.degel.re_frame_firebase.core.default_error_handler());
                                 ^

thheller14:10:24

@deg set :compiler-options {:language-in :ecmascript5}

deg14:10:25

Thanks! That goes at the top level of each cljsbuild? or inside the :compiler {...} map?

thheller14:10:22

not entirely sure, don’t use cljsbuild

deg14:10:56

ok, I'm trying now. Thanks again.

deg15:10:57

Yup, figured that out. (Sorry, didn't answer with the solution 'cuz I'm still working out the details. My case is a bit twisted with a Mies-based library being used by a cljsbuild'd project. Plus, family interruptions. ... embarrassed grin ...

deg15:10:32

@abs-zero - what's the context around that? It sounds like you need to run "lein figwheel" from the cmdline if that's your env or start it from Cider if you are in emacs or ...

abs-zero15:10:46

my "lein figwheel" is running

deg15:10:28

Has this project worked in the past, or is it a new project?

abs-zero15:10:11

just a new project, beginner here I restarted figwheel then it finally showed error on console I fixed it now thanks anyway

deg15:10:49

ok. good luck. Sadly, restarting things or even a lein clean are helpful way more often than we'd like.

abs-zero15:10:11

ok I intentionally made an error on the program but figwheel isn't printing any error

deg15:10:17

Ah, I've seen that sometimes working in an Emacs/cider environment. I've never looked at it carefully, but seems to happen when one file was changed since the last time Figwheel checked but the problem was in another file.

abs-zero15:10:47

this has happened to me plenty of times nothing is printed by figwheel on console when I make changes on file

abs-zero15:10:55

but it does live reload/hot reload

deg15:10:40

Figwheel echos errors to a popup in your browser. I don't know if it also prints to console.

abs-zero15:10:15

yeah it does normally

abs-zero15:10:29

but sometimes it shows "has not been compiled"

abs-zero15:10:39

like the photo above

abs-zero15:10:47

although figwheel is running

deg15:10:52

k. Over my pay grade, sorry! I'm going silent for a bit, but will be back later.

abs-zero15:10:05

okay no problem 😄

pesterhazy15:10:29

@abs-zero difficult to diagnose remotely without knowing more

abs-zero15:10:07

tried lein clean and different browser same problem after several saves

abs-zero15:10:25

I am also using reagent-template

abs-zero15:10:46

I will try reducing problem to minimal reproduction case 😄

pesterhazy15:10:57

If I'm really lost with a problem, I'll start with an empty template, make sure it works, then add back my code bit by bit.

pesterhazy15:10:45

It's annoying but sometimes the only way to uncover what usually turn out to be misconceptions on my part

abs-zero15:10:18

I reproduced it in brand new reagent-template

abs-zero15:10:47

(defn home-page []
  [:div [:h2 "Welcome toa Reagent"]]
  :)

abs-zero15:10:58

added : there and got the same problem

pesterhazy15:10:26

check figwheel_server.log

pesterhazy15:10:45

It should contain a compiler error. The same should also be shown in the terminal if you restart the repl

pesterhazy15:10:24

I've added it to the checklist above 🙂

abs-zero15:10:11

okay isn't there a fix to this? is this a bug? it would suck if I had to check log everytime 😕

pesterhazy15:10:43

The cljs code is basically too screwed up to compile, so it's not clear what figwheel should show

pesterhazy16:10:01

It's just a habit you acquire to check the terminal log.

pesterhazy16:10:02

I agree it's not ideal UX wise though - you need to check for errrors in multiple places

abs-zero16:10:16

I see. Thanks for the info 🙂

dimovich16:10:52

stumbled into a strange error

dimovich16:10:41

after advanced compilation, the element has no :on-change event attached

dimovich16:10:52

with no optimization everything works fine

dnolen17:10:06

@dimovich that usually means you’re missing externs somehow

dimovich08:10:17

solved by removing node_modules folder

pesterhazy17:10:19

@dimovich i.e. the issue is probably not in the snippet you showed

dimovich17:10:37

@dnolen @pesterhazy checking now... this started after adding a modified cljsjs module

pesterhazy17:10:20

watch out for any instances of js interop, (.method obj) or (.-property obj)

Aleh Atsman18:10:05

can someone advice a set of tools to build isomorphic clojurescript app?

Aleh Atsman18:10:12

Which engine to use on server side?

Aleh Atsman18:10:18

Which router to use?

ajs19:10:01

Can anyone comment on the differences between cljs-devtools and Dirac? Same author and both are billed as tools on top of Chrome DevTools. Having some difficulty understanding the differences in abstraction/application of these two libraries.

mikethompson19:10:14

@ajs if you use clj-devtools, any ClojureScript data structures you write (eg. println) to the js console will appear as EDN rather than js. This is a massive help. A can't-live-without-it kind of help. Dirac is a further step which actually gives you a ClojureScript REPL in DevTools. An alternative "console" to the regular js one.

ajs19:10:56

i assume then that the functionality does not overlap between the two, they are complementary?

ajs19:10:51

how apropos, thanks

ajs19:10:03

>This is obviously very advanced feature you would use debugging complex code once in 10 years