This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-31
Channels
- # architecture (5)
- # beginners (35)
- # boot (150)
- # cider (1)
- # clara (7)
- # cljs-dev (131)
- # cljsrn (10)
- # clojure (76)
- # clojure-austin (3)
- # clojure-berlin (1)
- # clojure-brasil (1)
- # clojure-chicago (2)
- # clojure-dusseldorf (1)
- # clojure-italy (30)
- # clojure-nl (2)
- # clojure-russia (40)
- # clojure-serbia (2)
- # clojure-spec (25)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (106)
- # core-async (29)
- # datascript (65)
- # datomic (38)
- # emacs (8)
- # funcool (8)
- # hoplon (6)
- # jobs (3)
- # klipse (93)
- # luminus (16)
- # lumo (4)
- # off-topic (2)
- # om (11)
- # onyx (13)
- # pedestal (4)
- # protorepl (3)
- # re-frame (40)
- # reagent (31)
- # ring (6)
- # ring-swagger (4)
- # slack-help (5)
- # spacemacs (13)
- # untangled (17)
- # vim (2)
Here's a spirtual successor to Enlive https://github.com/ckirkendall/enfocus#selectors
@itruslove I believe with specter[1] you are just one custom navigator-fn away from your goal đ [1] https://github.com/nathanmarz/specter
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))
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?
@looveh DId you require the namespace? I can see the locale file in my cljs compiler jar
@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!
not familiar with the google apis but I'd suspect they expect the name of the function to be called
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
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?
I'd like to use :preprocess
in conjunction with lein cljsbuild/doo. Any idea how to get there w/o hacking the plugin code?
@looveh you always have to require
stuff from goog
is not automatically available (unless some ns already loaded it)
@dnolen Got cljsbuild replaced already. Maybe I should really try to use doo as a library.
@dnolen Looking at figwheel, I guess the library route is the better and easier option. And doo seems to support it.
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
thereâs bidi and silk too, I see them used more and more
i find bide the most straightforward, ymmv https://github.com/funcool/bide
Thanks @lambdacoder and @dialelo - will give both a look. Appreciate the pointer đ
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.
@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
@mccraigmccraig Thanks! I love the re-frame
docs, should have looked there.
@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])))
Thanks. Then what's the use of a :get-initial-state
fn
returning a map?
What happens to that map? How is it used?
Iâve not use :get-initial-state
, so Iâm not exactly sure
Well, that says a lot. đ
@bostonaholic Any idea why I'd use the session over the main app-state?
session?
Looks like that's just a reagent-utils
thing.
yeah, and again. Iâm not sure. Never used reagent-utils
glad I can be so helpful đ
there is also #reagent to try
Ah...didn't realize that. Thanks for your help! It was good to see you the other night.
absolutely!
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?
@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
Some non-normative exposition is here if it helps: http://blog.fikesfarm.com/posts/2016-03-01-clojurescript-macro-sugar.html
@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
@moxaj you can probably pull it off with a single cljc file
depends on the file
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.
I've already separated the macro definitions from their usages, but that doesn't cut it
you may want to have a look at https://github.com/cgrand/macrovich
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.
;; 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
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=>
works for me?
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]}}
@moxaj are you on 1.1.0 now?
@anmonteiro yes, and windows, if that matters
can you tell me how you're trying to load the file exactly? i.e. how you're starting lumo
right
try lumo -vc .
instead
-v -c
is equivalent to -vc
, that's not the important part
directory structure is important
not sure if .
is cwd on windows
actually I think Lumo has the current dir as the default classpath so you can just omit the -c
option
@anmonteiro argh, my foo.cljc was messed up, ignore the infinite loop. seems to be working now
yeah, you need this patch in which made it to 1.9.293: https://github.com/clojure/clojurescript/commit/04751f337620279b0228856e4d224ae3d41abe72
oh my god it works .. it all works! too bad it takes 37 seconds to load my main namespace ^^ but i'm not complaining
you can use -K
for auto-caching or -k cache-folder
then only the first load will be painfully slow đ
@anmonteiro cool! just to mention, I think I got lumo working on travis-ci, needed some shenanigans
what do you mean by having lumo working in Travis?
oh cool
please link me your .travis.yml
if it's public
@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
cool, thanks
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
@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