This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-19
Channels
- # beginners (134)
- # boot (4)
- # cider (23)
- # clara (2)
- # cljs-dev (2)
- # cljsrn (4)
- # clojure (147)
- # clojure-austin (9)
- # clojure-berlin (2)
- # clojure-dusseldorf (2)
- # clojure-france (2)
- # clojure-italy (11)
- # clojure-russia (1)
- # clojure-spec (18)
- # clojure-uk (182)
- # clojurescript (40)
- # community-development (5)
- # cursive (29)
- # datascript (6)
- # datomic (18)
- # duct (6)
- # emacs (4)
- # events (1)
- # fulcro (46)
- # hoplon (5)
- # jobs-discuss (12)
- # keechma (1)
- # luminus (7)
- # lumo (1)
- # off-topic (11)
- # onyx (9)
- # parinfer (5)
- # protorepl (1)
- # re-frame (18)
- # reagent (23)
- # reitit (2)
- # ring (5)
- # ring-swagger (20)
- # schema (1)
- # shadow-cljs (32)
- # spacemacs (1)
- # specter (2)
- # vim (26)
Is this a valid use of externs inference?
(def ^js/SomeThing thing js/SomeThing)
I’d find something like this most common and think I’ve seen it somewhere before, yet none of the docs have this kind of example.In that particular example the typehint is inferred by js/SomeThing
itself so it is redundant
Oh so (def thing js/SomeThing)
would also have an implicit ^js/SomeThing
type hint?
@martinklepsch Anything js/...
will get added to the externs.
How can i go to some route without using # in secretary?
currently i am able to route to a path like localhost:3449/#home
but i would like it to be localhost:3449/home
Any ideas?
I am using Reagent & referred this link from reagent cookbook https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/add-routing
Thanks
@kumar1993sumit15 you want goog.history.html5history which uses pushState
hi, i’ve not tried yet, but you could look at bidi for routing plus the pushy library
https://pupeno.com/2015/08/26/no-hashes-bidirectional-routing-in-re-frame-with-bidi-and-pushy/
@robert-stuttaford hey thanks for the reply i'll try it out see if i can make it work @christopher.paul thanks for the tip i'll look into it when i get the time
@kumar1993sumit15 It is much easier to just install https://github.com/venantius/accountant It just takes a few lines of config and html5 history will be working like a charm.
Having some weird issues with goog.date.relative:
(goog.date.relative/format (- (.getTime (js/Date.)) 300))
Shouldn’t this return “5 minutes ago”?@martinklepsch Havent't looked into whether right or wrong, but the argument appears to be in milliseconds
(goog.date.relative/format (- (.getTime (js/Date.)) 300000))
Yeah, the docs indicate milliseconds: https://google.github.io/closure-library/api/goog.date.relative.html
@mfikes thanks that was part of the issue I had. the other part is that goog.date.relative/format
returns an empty string for dates older than 2 weeks 😄
I think I'm misunderstanding how a self-hosted ClojureScript project is structured & run. The tests that I run with lein tach lumo
work fine, but when I try and run my core file with lumo src/sherman/core.cljs
, the namespace I'm requiring is not found. Project is here: https://github.com/mathpunk/sherman
My hypothesis is, running a file with lumo is different than lein run
because lein knows all about the project from looking at the project.clj, and lumo is perhaps not doing that
I've just tried putting in a :main sherman.core
line into my project.clj, but that gives lein the impression I've got a Clojure namespace by that name, and I've got only a ClojureSCRIPT namespace
Lumo has a -c
arg for classpath, but I confess I haven’t used lumo, so I’m just passing on what I’ve heard about
I don't quite understand the brief descriptions of the command line options. When I figure this out, I'd like to expand the documentation a little: https://github.com/anmonteiro/lumo/blob/site/docs/RunningLumo.md
I tried adding a -main
function to sherman.core
and running lumo -c src -m sherman.core
, but no dice
The -c
needs to be followed by a list of directories containing the files you're trying to require in your cljs, but I'm not sure what the format for that is
Try lumo -c #(lein classpath) -m sherman.core
Whoops, no
lumo -c $(lein classpath) -m sherman.core
I'm regurgitating an answer I saw elsewhere, so that may or may not work
thanks @U06CM8C3V
:thumbsup:
@U0E9KE222 If it helps, most of the material describing Planck is applicable to Lumo. Planck has an extensive user guide here http://planck-repl.org and talks about -c
in the dependencies section.
Also writing a comment for pushing the PR on lumo
forward is a good idea. I wonder if at some point we should have a common doc for lumo
and planck
at least for the basics
Does anyone know how to get the following spec stuff - written in CLJC - to work in CLJS?
(defmacro opt-keys-spec [spec-name opt-keys req-type req-key]
(let [keys (eval opt-keys)]
`(s/def ~spec-name (s/and
#(contains-opt-keys? 1 % ~opt-keys)
(s/keys ~req-type [~req-key]
:opt ~keys)))))
It works in CLJ but fails because eval
doesn’t work/exist in CLJS and it’s doing my head in :< Maybe looking for an alternative to eval
or a CLJS-specific way to do it?
Any help would be greatly appreciated, thanks in advance.@lachlan737 For JVM-ClojureScript, the macro would be in a Clojure file, and eval
is available at macroexpansion time. Note that in your macro, eval
is not in the syntax-quote portion. In other words it is called at expansion time (in Clojure).
FWIW, that macro expands for me.
cljs.user=> (require-macros 'foo.core)
nil
cljs.user=> (macroexpand '(foo.core/opt-keys-spec ::abc :a :req :rk))
(s/def :cljs.user/abc (s/and (fn* [p1__426__427__auto__] (foo.core/contains-opt-keys? 1 p1__426__427__auto__ :a)) (s/keys :req [:rk] :opt :a)))
If on the other hand you are in self-hosted ClojureScript, then it is generally possible to define your own eval
and then make use of it. FWIW, both Lumo and Planck do that to satisfy the need for eval
in this macro: https://github.com/clojure/clojurescript/blob/f55b19b89e98a210a89151f52e67567108c536cf/src/main/cljs/cljs/spec/test/alpha.cljc#L113