This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-04-06
Channels
- # beginners (95)
- # boot (3)
- # cider (13)
- # cljs-dev (9)
- # cljsjs (1)
- # cljsrn (35)
- # clojure (78)
- # clojure-dev (5)
- # clojure-italy (6)
- # clojure-nl (9)
- # clojure-russia (13)
- # clojure-spec (1)
- # clojure-uk (74)
- # clojurescript (59)
- # community-development (6)
- # core-async (41)
- # css (110)
- # data-science (2)
- # datomic (22)
- # defnpodcast (1)
- # devcards (1)
- # docs (1)
- # editors (6)
- # emacs (51)
- # figwheel (1)
- # fulcro (66)
- # jobs (1)
- # jobs-discuss (75)
- # lumo (51)
- # mount (2)
- # off-topic (33)
- # pedestal (24)
- # proton (3)
- # re-frame (29)
- # reagent (92)
- # reitit (16)
- # shadow-cljs (16)
- # spacemacs (4)
- # specter (6)
- # vim (6)
- # yada (7)
the trick here is that an interface can't extend anything, but two things extending the same interface or protocol is how we tend to do things
also composing interfaces - implementing multiple interfaces to make one thing
The question I meant to ask:
Should I be using :import
or require
for goog.fx.Dragger
. My thought is that it should be import
because Dragger
is a class. see https://google.github.io/closure-library/api/goog.fx.Dragger.html
but then this class also has enums that can be imported at Dragger.EventType
To take this thought to the next step, what happens when enums from different class have the same names like:
[goog.events EventType]
[goog.fx.Dragger EventType]
The above won't work because the second EventType
overwrites the first. Would this mean we just have to do the following:
[goog.events.EventType]
[goog.fx.Dragger.EventType]
and then reference the full name each time?@tkjone You would be able to get away with import
ing one of the EventType
s while using the other one’s full, namespace-qualified name
Anyone know much about Cursive? I can't get Clojurescript to work in the REPL. It'll load files fine as long as they don't use any external libraries.
Hey! I am using cljs-ajax like this :
(defn signin
"Try to signin using email and password"
[{ :keys [email password handler error-handler]}]
(POST (str uri-host "/users/password_signin")
{:params {:email email
:password password}}
:format :json
:handler handler
:error-handler error-handler))
to post json, and it sends transit, not json. Is there anything wrong with this? Used ajax-request, and it worked. very strange :thinking_face:is there someone with bigquery experience ?
@troglotit Looks like :format
, :handler
, and :error-handler
aren't part of the options map
but it does have em according to this: https://github.com/JulianBirch/cljs-ajax#getpostput
Not sure what you mean. In your example those parameters aren't included in the map literal {}
Hi there! Anyone know what this means? Uncaught TypeError: Cannot read property 'ReactCurrentOwner' of undefined
How can I debug the advanced-compiled reagent/re-frame-app?
Hello guys
(read-line) can read integers as well ?
For reading ints
(read-int) ?
read-int is not valid
you can define read-int
like so:
(def read-int (comp (fn [s] (Integer/parseInt s)) read-line))
Hi sundar!
Thanks for the reply !
Is that function anonymous
yeah, it shows up in stack traces as
clojure.core/comp/fn core.clj: 2560
boot.user$fn__2470.invoke : 1
to have it show up as boot.user$read_int.invoke
you can define it fully like (defn read-int [] (Integer/parseInt (read-line)))
Gracias :)
How do you write and store your doodling ? I write little code with data.csv and spec-provider to explore some files. Not something I really want to put in an application, but I would like to put in a repository for futures explorations. I create a “app” with leiningein with seems overkill, but that’s the only way to write Clojure I know at the moment. Maybe I should look at deps.edn, ... ? Do you have some good pointers (blog posts, articles, ...) on the subject ?
yeah deps.edn is much lighter; the official docs are good: https://clojure.org/guides/deps_and_cli
Thanks !
I like that you can use clj
to fire up a REPL with a set of dependencies in the command-line arguments, so you don't need a "project".
It's one of the things I really like about Boot vs Leiningen.
There's lein-try
, but then you need that in your personal config etc.
boot -d some-group/the-artifact repl
will fetch the latest (non-snapshot) release of that project and fire up a REPL with it. With clj
you can do clj -Sdeps '{:deps {some-group/the-artifact {:mvn/version "RELEASE"}}}'
but that's a lot more verbose.I also like that Boot lets you load new dependencies at runtime into your REPL, so you don't have to stop your REPL, edit some file, start the REPL back up...
I think Boot is a lot more beginner-friendly -- but Leiningen is older/more established, so nearly all the tutorials out are written for lein
¯\(ツ)/¯
Hmm, I thought I'd seen folks talking about Figwheel in #boot (but I don't pay much attention to cljs stuff).
well, i just use adzerk-oss/boot-reload, but bhauman/lein-figwheel (naturally) only mentions Lein, and boot-clj/boot-figreload is incomplete according to the readme. perhaps there's a way to use figwheel-sidecar with boot, but i never really looked into it 😛
the new figwheel-core being worked on works with clj
though, so that would probably work with Boot too
@seancorfield Thank you for all this feedback ! (I should activate some mails notifications, I don’t open Slack during 3 days and nearly miss you response.) I need to say I love this community, so helpful, so beginners friendly.
@timok I’m not sure exactly what your issue is, but based on some googling, I’m seeing reports of people getting this error when they have multiple React libs with different versions, especially React 15 vs 16. Try lein tree :deps
to see if you can spot any conflicting React versions and if lein recommends any exclusions.
@U06CM8C3V Hi! Thanks for the reply. I was already looking into this and really, I am feeling lost here. I changed a lot of stuff now to get back to a running state.
lein deps :tree
does show me a lot of advices but there is nothing about react. Is it possible that google closure is the issue here?
I don’t know enough about it to really tell, unfortunately. I tend to doubt it though, sounds like something inside React is unhappy
maybe when I exclude react for a specific library? that this library needs e.g. a newer version?
Are you excluding any libraries at the moment?
And that fixed it for you?
no not until now...maybe I need to systematically approach this and try all the combinations...but the thing is, that running the uberjar on its own works and when deploying it to a server it does not and that's an indicator that it has to do with something else...
bummer
kind of works now...but no idea why...with these specific react dependencies and no excludes...
thanks! @U06CM8C3V
Sounds good. Sometimes I think removing a dependency might leave behind bits of code that should have been removed. The weirder things get, the more I do lein clean
, out of sheer paranoia.
I'm trying to use clj-http
's convenient :as :json
option to turn JSON into a Clojure map, but the OData endpoint I'm using returns annoying JSON field names like "[email protected]". Some functions seem to handle it just fine, but things like keys
or map
blow up because of the "@". I need the data the keys provides, and the keys are dynamic, so I can't deal with each key specifically. Any ideas on how to succinctly deal with the bad characters?
I think you need to use string key instead of keyword keys. so :as :json-string-keys
Ah, ok. That would solve it. Thanks!
@d4hines also, (keyword "[email protected]") does work - but much better to use strings instead of keywords for that kind of data
Ok, cool. Fortunately, :json-string-keys
is working beautifully.
I'm pretty puzzled how to use cljs-ajax library correctly. I have implemented a Clojure/Ring backend and tested with curl and Postman that both the GET and the POST interfaces work properly. I have configured the required cors settings. In ClojureScript frontend when using the cljs-ajax library to send a GET request everything works properly. But when sending a POST request (a map of a couple of key/value pairs as json) I get reply: XMLHttpRequest cannot load <POST url>. Response for preflight has invalid HTTP status code 400. And the weird thing is that the browser seems to send OPTIONS instead of POST. I'd be happy to find some working example to check what I have misunderstood.
@kari.marttila are you sending your GET and POST to the same url specified in exactly the same way?
unlike curl, a cross origin request needs a preflight and cors setup
it will send OPTIONS first iirc and the backend has to be ready to cooperate
> The CORS specification mandates that requests that use methods other than POST or GET, or that use custom headers, or request bodies other than text/plain, are preflighted.
(quote from my above http://mozilla.org link)
@kari.marttila the root of your problem is not cljs-ajax, it’s that you just don’t have cors setup correctly
Ok. Thanks. I'll investigate the issue now that I now what to fix. Thanks. 🙂
@lee.justin.m and @noisesmith: Any suggestions what should I add in the Clojure/Ring application side? I have currently configured the cors settings as: (assoc-in [:headers "Access-Control-Allow-Origin"] "*") (assoc-in [:headers "Access-Control-Allow-Headers"] "X-Requested-With,Content-Type,Cache-Control") (assoc-in [:headers "Access-Control-Allow-Methods"] "GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS") (assoc-in [:headers "Content-Type"] "application/json") (assoc-in [:headers "Access-Control-Max-Age"] "1728000")
@kari.marttila Have you looked at the ring-cors
middleware to do this automatically for you?
(let [h (ring-cors/wrap-cors handler
:access-control-allow-headers #{"accept"
"authorization"
"content-type"
"origin"}
:access-control-allow-methods [:delete :get
:patch :post :put]
;; 24 hours (in seconds) -- note that only Firefox
;; will honor this; other browsers cap lower!
:access-control-max-age "86400"
:access-control-allow-origin #".*")]
(fn [req]
(h req)))
for example(It doesn't improve the configuration much over what you're doing manually, but it handles the OPTION
preflight check automatically)
Maybe this should be obvious, apologies if it is, with the clj tool is there a recommended way to integrate clojure.test?
@drewverlee Did you see my dot-clojure deps.edn
file? I posted the link to GitHub in a few places...
clojure.test
is "built-in" (part of the main Clojure JAR) so you can just use it in code without additional dependencies -- so the key steps with clj
are: adding test
as a path (or wherever your test code lives) and adding some sort of test runner (such as Cognitect's test-runner
project). https://github.com/seancorfield/dot-clojure/blob/master/deps.edn --
clj -A:test:runner
lets me run testsclj -A:test:runner:1.7
will run tests using Clojure 1.7, for exampleI separate the test paths/deps from the runner so that I can start an nREPL server with tests on the classpath
clj -A:test:nrepl
Yea. Thanks @seancorfield. I somehow missed it in the offical docs to: https://clojure.org/guides/deps_and_cli#extra_paths
(hmm, I don't have Clojure 1.7 in my deps.edn
but I do have that alias in core.cache
and core.memoize
which both use clj
/ deps.edn
for local dev/testing)
So, multi-version testing of core.cache
https://github.com/clojure/core.cache/blob/master/deps.edn is
for v in 1.6 1.7 1.8 1.9 master; do clj -A:test:runner:$v; done
Thanks @seancorfield! I'll try that tomorrow. It's already midnigh in Finland, got to go to bed.