This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-21
Channels
- # arachne (1)
- # aws-lambda (50)
- # beginners (10)
- # boot (59)
- # capetown (4)
- # cider (9)
- # cljsjs (27)
- # clojure (249)
- # clojure-berlin (8)
- # clojure-finland (7)
- # clojure-germany (1)
- # clojure-italy (6)
- # clojure-nl (7)
- # clojure-russia (91)
- # clojure-spec (100)
- # clojure-uk (61)
- # clojureremote (2)
- # clojurescript (171)
- # core-async (11)
- # cursive (31)
- # data-science (1)
- # datascript (2)
- # datomic (11)
- # dirac (2)
- # emacs (16)
- # events (1)
- # hoplon (142)
- # juxt (4)
- # lein-figwheel (9)
- # leiningen (10)
- # luminus (7)
- # lumo (44)
- # mount (3)
- # off-topic (150)
- # om (18)
- # onyx (5)
- # perun (12)
- # planck (12)
- # protorepl (13)
- # re-frame (28)
- # reagent (8)
- # ring (1)
- # ring-swagger (10)
- # spacemacs (2)
- # specter (11)
- # sql (14)
- # untangled (99)
- # vim (18)
- # yada (2)
@qqq clojure.tools.reader
Hey all. I'm somewhat of a CLJS newbie. I'm trying to play around with gundb, however I notice that it's not part of the cljsjs. I'm very happy to add it. I just require a little direction
Wondering what's the trick to get it into IntelliJ so things compile and behave as you'd expect.
Does not work for me. Intelli does not like those <module>pom-main.xml</module>
entries. Next issue I hit is duplicate sources due to generated sources.
Thing is: I'd like to get me feet wet on commonjs stuff. Which seems to be quite in flux these days.
think I just referenced the sources for my stuff, never actually tried to compile it
if anyone has the inclination, i would be really happy to hear some harsh criticism of this https://github.com/ashnur/cljs-combo-network/blob/master/src/combo_network/core.cljs particularly about stuff i could do differently without hurting performance. but i am open to anything new. I use def at a lot of places because those variables will be in the state for the react stuff eventually, not globals, but i already like to change them and see how the graph behaves differently. My main pain points are the ticked and the update functions, this approach is coming from d3 but I don't like it too much, especially because it's so easy to mess up the drawing algorithms. I am looking for some better but still fast abstractions, if there are any. Thanks in advance 🙂
Would be useful to know what the project is about @ashnur 🙂
@ashnur I'm too busy but I would recommend throwing your performance assumptions out of the window and rewrite it completely with CLJS idioms in mind
https://github.com/ashnur/cljs-combo-network/blob/master/src/combo_network/core.cljs#L86-L88
@thheller you said you are busy, for me this is not urgent, if some other time you would have more time to pick on it 🙂
i should also remove the mess from draw-message, i just didn't know which direction i will go
assuming a project has both backend and frontend in Clojure(script)
is it worth to have it all in the same project?
You can probably find ways to share code anyway, and maybe with a single project you might add other complications for deployment or libraries changes
so there would be more flexibility in having them separate I guess
but things like Chestnut by default add both compojure and all the clojurescript stuff for exampe
Having them together will in general be easier. Your backend and frontend will evolve together and so having a shared history makes things easier.
There are benefits to having it separate as well. Main reason would be if you're deploying them separately and want to be able to ship features in frontend without having to redeploy the backend and vice versa
But in general unless you have separate teams doing front and back I would probably keep them together in one repo
@andrea.crotti it’s hard to think of common cases where having them separate is better - unless it’s a large pre-existing project and integration is impractical for some reason
Hey everybody, I’m trying to write a reagent frontend using re-frame
and sente
. I got everything working as described in the various readmes and issue comments in the sente repo, but I’m struggling with my authentication layer which uses buddy-auth
‘s token
backend. Before trying to integrate sente, I got it working via cljs-ajax
(sending an Authorization
header with the token) – how do I best approach this? Should I only connect when I have a token (which would mean acquiring the token in a more ‘traditional’ way, right?), or use sente’s chsk-reconnect!
and implement the auth flow with sente, too? Another problem: When using the ajax-opts
option in sente/make-channel-socket!
, I can’t seem to get it to send the Authorization header, while params
work as advertised
(If this is not the right place: is there a more specific channel I can post this question to?)
@nicoschneider I think buddy-auth sends a cookie, which adds some session data to every request from the client. Not sure if that travels with websocket connection, I doubt that it works, except maybe authenticating initially and establish a websocket connection and keep it without looking for the session data again. As for sente, I found it simpler to just use http-kit which sente bases most of its functionality on, in case sente makes your hairs gray.
@hlolli thanks, but I’m pretty set on sente (or similar?) since I have dreams about re-frame + websocket events. I use aleph as the http server (more because of the novelty than anything else, really), and it works so far. The cookie seems to work over ws connection – so you’re saying I can grab user identity info from the cookie in sente’s :user-id-fn
?
(minus the naming in example code, nothin really makes my hair grey with sente :))
hello. Does anyone run cljs code in ios safari? I’m not sure, but it seems it just loads resources in a random order and I get errors because of this, different set of errors on every page reload.
I have a middleware
(defn authenticate
[handler]
(friend/authenticate handler
auth-config))
it will fetch the data from the cookie, I think the function friend/authenticate is bit magical to me, but works.and auth-config
(def auth-config
{:allow-anon? true
:login-uri "/login"
:default-landing-uri "/"
:unauthorized-handler (wrap-json-unauth default-unauthorized-handler)
:unauthenticated-handler (wrap-json-unauth friend/default-unauthenticated-handler)
:credential-fn check-credentials-and-store-session
:workflows [(workflows/interactive-form)]})
I don’t understand why I only get these errors in ios safari: https://www.dropbox.com/s/o0r9hre942il1po/Screen%20Shot%202017-02-21%20at%2018.24.54.png?dl=0
I just added the cljsjs/ag-grid package (which I wrote) to a project and it clearly defines cljsjs.ag-grid but when I try requiring it, I get an error: "No such namespace". Any ideas why this could be happening?
new in Lumo 1.2.0: https://twitter.com/anmonteiro90/status/834064263245279233
anmonteiro: Absolutely awesome! Thanks for your work on lumo, I use it more and more!
Thanks, appreciate it. Have fun with the new release :-)
^ you can now compile CLJS projects (with Google Closure optimizations too!)
could someone help me to figure out why, for example, goog/asserts.js loads before goog/util.js where the goog.debug.Error
is defined so I get TypeError: undefined is not an object (evaluating ‘goog.debug.Error’)
: https://www.dropbox.com/s/o0r9hre942il1po/Screen%20Shot%202017-02-21%20at%2018.24.54.png?dl=0
Hey all. I'm trying to create a cljsjs package ( https://github.com/cljsjs/packages/pull/1007 ). However, when trying to minify file for production use I'm getting the following error:
Minifying gun.inc.js
Feb 21, 2017 11:02:26 AM com.google.javascript.jscomp.LoggerErrorManager println
SEVERE: /home/peter/.boot/cache/tmp/home/peter/code/cljs-packages/gun/erw/u2qisy/cljsjs/gun/development/gun.inc.js:676: ERROR - Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option.
lex: ((lex) || (lex))? Gun.is.rel.ify(lex) : lex,
^
Sifting output files...
I'm not really sure what to do. Would someone point me in the right direction.
I have looked at specifying the language_in
option, however literally none of the other cljsjs projects do this. So I'm not sure that it's the correct directionWhat’s the goto way to ‘merge’ a cljs map with a JS object?
I write (clj->js (merge (js->clj obj) m))
, but wonder if there is a better way
@borkdude I use goog.object/extend
You wanna avoid clj->js
whenever you can
@anmonteiro Why is that?
Performance
@borkdude if you know your maps are shallow, it should be OK
Now if you're nesting structures you'll pay the perf cost
yeah, I figured it would be more costly. I almost went for Object.assign, but this didn’t feel right. goog.extend it is
@anmonteiro This should get me to the newest Lumo right? npm update -g lumo-cljs
@dnolen Thanks and in the second argument I often can get away with a #js
literal, which would be even cheaper
@borkdude also hold on to the arg you pass to gobj/extend
, it mutates it
I'm not too familiar with NPM but I pushed 1.2.0 last night
Weird, try uninstalling first maybe?
@petr I would try directly on either the GitHub issue pages or #cljsjs
I was silly not to think of that channel. THank you @richiardiandrea
@anmonteiro Since you're here... I noticed that when I use the cljs variant of core.async (andare), script startup times go up a lot, up to 40 seconds for simple scripts. Is that expected? Is there any way to speed it up?
@mrchance it's because of the time it takes to compile the core async macros
Use lumo -K
for auto cache or lumo -k your-dir
for manual cache
Subsequent runs will use cached JS
@mrchance There was also a big perf regression that really hits Andare hard under self-hosted ClojureScript. It was fixed in 1.9.473 http://dev.clojure.org/jira/browse/CLJS-1932
@mfikes Haha, this slack is so awesome, it's like the author of every cool library I use is here to help 😉 Thanks, I'll give it a shot! Probably not in lumo yet though, right?
I'm finding that the :fn-scope
of the macro &env
is empty when I'm in a function with multiple or variadic arity. Is that expected, or a bug?
(defn fn-scope-single-arity [a]
(prn (fn-scope)))
(defn fn-scope-multi-arity
([a] (prn (fn-scope)))
([a b] (prn (fn-scope))))
(defn fn-scope-var-arity [& as]
(prn (fn-scope)))
(fn-scope-single-arity 1)
(fn-scope-multi-arity 1)
(fn-scope-multi-arity 1 2)
(fn-scope-var-arity 1 2 3)
the first gives me [{:name fn-scope-single-arity, :info {…}}]
, while the rest all print []
@peeja I don't think there is an official API for this stuff. so it is neither expected nor a bug.
@peeja also be careful with this stuff, (defn fn-scope-single-arity [a] (let [foo 1] (prn (fn-scope))))
is another scope
We're using a macro to annotate Om components with the name of the function for styling. It's a nice trick, and it's been working fine for months, but apparently we've never tried to make a component function variable arity before.
I'm going through the guide at https://clojurescript.org/guides/quick-start. In the "Running ClojureScript on Node.js" section, I'm getting an error when I try to run my code with node:
W:\Personal\Coding\Discord\selfbot-cljs\out\goog\dom\dom.js:2242
this.document_ = opt_document || goog.global.document || document;
^
ReferenceError: document is not defined
at new goog.dom.DomHelper (W:\Personal\Coding\Discord\selfbot-cljs\out\goog\dom\dom.js:2242:60)
...etc.
I know there's no document
in node, of course, but why is Google Closure looking for it?
@tech_hutch something in your code (or dependencies) imports it most likely
You mean Google Closure, as a whole? I thought ClojureScript itself used it?
I'll post my code. It's very short.
@tech_hutch you’ve elided the stacktrace which tell us which file is trying to load goog.dom
Oh, I just realized something.
In "src", I have both "selfbot_cljs" and "selfbot-cljs", which both contain a "core.cljs". I renamed that folder at one point, because I remembered it saying somewhere that the folder path had to have hyphens replaced with underscores. I don't know how I ended up with both folders, but that's probably the problem.
Thanks for the help. (I haven't tested it yet, though, since I'm heading home now.)
Hey all. i'm a complete Js newbie. Would anyone be so kind as to tell me if this is the correct way to do things in cljs? https://www.refheap.com/9d248106209b20cccf68299d5
I just put it inside of a reagent view because it seemed like a simple environment to just mess around in
btw. your usage of js-obj
also looks suspicious to me, js-obj takes arguments k1 v1 k2 v2 … kN vN, not a map AFAIK
@thheller one thing I'm unsure of how to do is gun.get('mark').on(function(data, key){console.log...}