Fork me on GitHub
#clojurescript
<
2017-01-31
>
escherize00:01:49

What kind of searching do you want?

darwin00:01:42

@itruslove I believe with specter[1] you are just one custom navigator-fn away from your goal 🙂 [1] https://github.com/nathanmarz/specter

tianshu00:01:45

For infer-externs,

(defn foo [^js/Event event]
  (.focus (.-target event))
(.-target event) can be inferenced to js/EventTarget, inferred_externs.js generated successfully (with EventTarget.prototype.focus; inside) and everything works fine, but still get the warning:
Cannot resolve property focus for inferred type js/EventTarget in expression (. (.-target e) focus).
------------------------------------------------ Finally, it works when I add type hint ^js/HTMLInputElement like this:
(let [^js/HTMLInputElement ele (aget e "target")]
  (.focus ele))

dvingo03:01:26

is specify only available in cljs and not clj? I don't see it in the clojure source

dnolen04:01:12

@danvingo not currently possible in Clojure - only exists in ClojureScript

dvingo04:01:26

got it, thanks!

Niclas10:01:56

I’m unable to reach the module js/goog.locale in cljs, is there a reason why this isn’t included from the closure library?

rauh10:01:03

@looveh DId you require the namespace? I can see the locale file in my cljs compiler jar

Niclas10:01:05

@rauh I was unable to reach the module in a live repl session, but adding (:require [goog.locale]) to a random ns in the project and recompiling seems to have made the module included in the compilation, so that fixed it. Thanks!

thheller10:01:07

@tomaas pretty sure :data-* attributes can only take strings, not functions

thheller10:01:48

not familiar with the google apis but I'd suspect they expect the name of the function to be called

tomaas10:01:59

@thheller, thanks. I passed it as a string but the function does not get call anyhow

thheller11:01:09

if you are doing this https://developers.google.com/identity/sign-in/web/build-button I suspect you'll need to call gapi.signin2.render as per example

tomaas14:01:29

having some component(file) I want to dispatch to some route. In the template of reagent the routes are defined with secretary library. If I call (secretary/dispatch! "/charts"), the content of charts is loaded but the url path does not change. Should I just set the url using location or is there some better way to do this?

deas14:01:58

😢

deas14:01:00

I'd like to use :preprocess in conjunction with lein cljsbuild/doo. Any idea how to get there w/o hacking the plugin code?

dnolen14:01:30

@looveh you always have to require stuff from goog is not automatically available (unless some ns already loaded it)

dnolen14:01:19

@deas pretty sure :preprocess is going to require plugin support

deas15:01:17

@dnolen I was desperately looking for a way around, but seems it is just not possible.

dnolen15:01:28

not possible

dnolen15:01:48

but also you’re talking about alpha quality new functionality 🙂

deas15:01:50

@dnolen Was considering something along the lines of :injections.

dnolen15:01:03

so you should expect to be on your own for at least a few months

deas15:01:30

I'm on my own anyways. 😉

dnolen15:01:36

heh 🙂

dnolen15:01:09

I imagine lein-doo probably can work just as a lib

deas15:01:16

@dnolen Does the :injections approach sound reasonable to you?

dnolen15:01:20

I don’t really understand why putting stuff in project.clj is a requirement

dnolen15:01:26

I’ve never used :injections

dnolen15:01:32

I’ve stopped using lein for build config

deas15:01:19

I'd hate to drop doo/cljsbuild because they worked so nice. Up until now that is. 😕

dnolen15:01:42

I don’t see why you need to drop doo

dnolen15:01:48

cljsbuild maybe

dnolen15:01:23

I’m not familiar with doo internals, but ideally it can work as a library

dnolen15:01:26

just like Figwheel

deas15:01:02

@dnolen Got cljsbuild replaced already. Maybe I should really try to use doo as a library.

deas15:01:09

@dnolen Thanks. Will try both ways.

deas15:01:22

@dnolen Looking at figwheel, I guess the library route is the better and easier option. And doo seems to support it.

eugekev16:01:48

Is the best way to add routing to a Reagent app still Secretary? Seems like it hasn’t been updated in a couple years. https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/add-routing

Jeremie Pelletier17:01:02

there’s bidi and silk too, I see them used more and more

dialelo17:01:26

i find bide the most straightforward, ymmv https://github.com/funcool/bide

eugekev17:01:48

Thanks @lambdacoder and @dialelo - will give both a look. Appreciate the pointer 🙂

danielglauser19:01:55

I'm new to Reagent, are there conventions for managing component local state? It seems that I could let a local atom at the top of the fn the defines the component, let a reagent/atom, or something else? Should I be initializing said atom in an :get-initial-state fn? Happy to RTFM, can't seem to find an example that covers this.

mccraigmccraig19:01:47

@danielglauser form-2 or form-3 components with a let around the inner function - see here for details of the different component forms https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components

danielglauser19:01:35

@mccraigmccraig Thanks! I love the re-frame docs, should have looked there.

bostonaholic19:01:27

@danielglauser you are correct. If you want component local state, use let to make an atom from within the component, like so:

(defn timer-component []
  (let [seconds-elapsed (r/atom 0)]
    (fn []
      (js/setTimeout #(swap! seconds-elapsed inc) 1000)
      [:div
       "Seconds Elapsed: " @seconds-elapsed])))

danielglauser19:01:35

Thanks. Then what's the use of a :get-initial-state fn returning a map?

danielglauser19:01:55

What happens to that map? How is it used?

bostonaholic20:01:42

I’ve not use :get-initial-state, so I’m not exactly sure

danielglauser20:01:17

Well, that says a lot. 🙂

danielglauser20:01:14

@bostonaholic Any idea why I'd use the session over the main app-state?

danielglauser20:01:31

Looks like that's just a reagent-utils thing.

bostonaholic20:01:07

yeah, and again. I’m not sure. Never used reagent-utils

bostonaholic20:01:13

glad I can be so helpful 😜

bostonaholic20:01:30

there is also #reagent to try

danielglauser20:01:48

Ah...didn't realize that. Thanks for your help! It was good to see you the other night.

moxaj20:01:55

why doesn't Implicit macro loading (as described at https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces) work with self-hosted clojurescript? Or it does and i'm doing it wrong?

mfikes21:01:32

@moxaj Implicit macro loading works with self-hosted ClojureScript. For example, if src/foo/core.cljs contains:

(ns foo.core
  (:require-macros foo.core))
and src/foo/core.clj contains:
(ns foo.core)

(defmacro add [a b] `(+ ~a ~b))
then you can do this in either Lumo or Planck:
$ lumo -qc src
cljs.user=> (require '[foo.core :as foo])
nil
cljs.user=> (foo/add 1 2)
3

moxaj21:01:28

@mfikes I see, I read your blog posts btw, but I thought I'd be able to pull it off with a single cljc file

anmonteiro21:01:46

@moxaj you can probably pull it off with a single cljc file

anmonteiro21:01:51

depends on the file

moxaj21:01:02

note that i'd like to support 3 platforms (clj, cljs and self-hosted cljs)

mfikes21:01:26

The example in the “Loop” section at the bottom of http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html works with more recent compilers (thanks to António’s work), if you remove the conditional stuff.

moxaj21:01:34

I've already separated the macro definitions from their usages, but that doesn't cut it

moxaj21:01:39

i'll check that out

mfikes21:01:32

FWIW, Planck 1.17 can’t support the Loop thing I just mentioned, nor Macrovich, because it predates António’s compiler revision, which I believe shipped with 1.9.293.

moxaj21:01:28

;; foo.cljc
(ns foo
  #?(:cljs (:require-macros [foo])))

(defmacro m [] 0)

;; in lumo repl
(require '[foo :as f :refer [m]])
(foo/m) ;; fails
(f/m)   ;; fails
(m)     ;; works

anmonteiro21:01:00

@moxaj

Lumo 1.1.0
ClojureScript 1.9.456
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[foo :as f :refer [m]])
nil
WARNING: foo is a single segment namespace at line 1 foo.cljc
WARNING: foo$macros is a single segment namespace at line 1 foo.cljc
cljs.user=> (foo/m)
0
cljs.user=> (f/m)
0
cljs.user=> (m)
0
cljs.user=>

anmonteiro21:01:15

works for me?

moxaj21:01:38

Lumo 1.0-alpha ClojureScript 1.9.293 i'll update these and try again

moxaj22:01:56

Loading result: {:error #error {:message Could not require foo in file foo.cljc, :data {:tag :cljs/analysis-error}, :cause #object[RangeError RangeError: Maximum call stack size exceeded]}}

anmonteiro22:01:28

@moxaj are you on 1.1.0 now?

moxaj22:01:41

@anmonteiro yes, and windows, if that matters

anmonteiro22:01:44

can you tell me how you're trying to load the file exactly? i.e. how you're starting lumo

moxaj22:01:21

lumo -v -c foo.cljc

anmonteiro22:01:25

try lumo -vc . instead

anmonteiro22:01:42

-v -c is equivalent to -vc, that's not the important part

anmonteiro22:01:50

directory structure is important

anmonteiro22:01:06

not sure if . is cwd on windows

anmonteiro22:01:58

actually I think Lumo has the current dir as the default classpath so you can just omit the -c option

moxaj22:01:17

@anmonteiro argh, my foo.cljc was messed up, ignore the infinite loop. seems to be working now

moxaj22:01:39

so upgrading lumo and cljs resolved it, hmm

moxaj22:01:53

oh my god it works .. it all works! too bad it takes 37 seconds to load my main namespace ^^ but i'm not complaining

anmonteiro22:01:55

you can use -K for auto-caching or -k cache-folder

anmonteiro22:01:03

then only the first load will be painfully slow 🙂

moxaj22:01:28

@anmonteiro cool! just to mention, I think I got lumo working on travis-ci, needed some shenanigans

anmonteiro22:01:09

what do you mean by having lumo working in Travis?

moxaj22:01:41

I can use it for automatic testing

anmonteiro22:01:41

please link me your .travis.yml if it's public

moxaj22:01:29

@anmonteiro I believe this is all you need (and npm install -g lumo-cljs in before_script)

addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - libstdc++-4.9-dev

moxaj22:01:49

without that package, lumo wouldn't install for me

anmonteiro22:01:53

cool, thanks

ejelome23:01:35

any offline documentation for clojurescript available for zeal? 🙂

ejelome23:01:33

I saw this, but not sure if it will even work for zeal (and it takes forever to create a docset) https://github.com/cljs/api#offline-docset-for-dash

richiardiandrea23:01:57

@ejelome it is available from the dash users as separate download, but for zeal users there is some fiddling because they have not (the last time I checked) adapted to the new dash format