This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-18
Channels
- # alda (8)
- # aws (1)
- # bangalore-clj (1)
- # beginners (55)
- # boot (114)
- # capetown (2)
- # cljs-dev (51)
- # cljsjs (1)
- # cljsrn (14)
- # clojure (119)
- # clojure-belgium (6)
- # clojure-brasil (9)
- # clojure-conj (2)
- # clojure-greece (1)
- # clojure-korea (2)
- # clojure-poland (12)
- # clojure-russia (64)
- # clojure-spec (12)
- # clojure-uk (60)
- # clojurescript (159)
- # code-reviews (2)
- # component (4)
- # core-matrix (2)
- # cursive (79)
- # datascript (7)
- # datomic (2)
- # defnpodcast (4)
- # events (2)
- # hoplon (13)
- # jobs (2)
- # lein-figwheel (1)
- # off-topic (10)
- # om (42)
- # onyx (60)
- # pedestal (5)
- # perun (7)
- # rdf (4)
- # re-frame (4)
- # reagent (21)
- # ring-swagger (25)
- # schema (1)
- # spacemacs (52)
- # specter (1)
- # utah-clojurians (1)
- # yada (5)
anyone here have good/bad things to say about re-com ? I'm a big fan of reagent, and trying to figure out if it's worth the time to pickup the entire re-com library
(suggestions of alternatives also welcome) -- looking for a "UI kit" with more than just basic div elements
@hwk: I like it, I built one re-frame application with it and it really, really sped things up compared to doing the same type of work without it.
@shaun-mahood : I am using reagent. I am reading re-frame documentation. There seems to be lots of buzzwords. What does re-fame actually do?
@hwk: It gives you a well thought out, performant and scalable architecture to build your application with - if the way it works suits your needs, I think it's an excellent structure to use, but it's certainly not necessary if you are happy with the structure you've built using reagent.
I think it would be worth trying if you are already comfortable with reagent, it's pretty easy to understand the basics and it may give you some ideas you can implement even if you don't end up using it.
@shaun-mahood : maybe I'm not seeing it -- is there a tutorial for re-frame somewhere? the devcards / reagent tutorials are jaw dropping, but with re-frame, I have yet to see a demo that makes me go "wow, this bonkers"
@hwk: I think the best resource right now for that kind of thing is either going to be in the docs somewhere (https://github.com/Day8/re-frame/tree/master/docs), or one of the external resources (https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md), or in one of the Lambda Island videos (https://lambdaisland.com) though I haven’t watched the newest re-frame one yet. I’m giving a re-frame talk at the Conj, so hopefully that will go a bit of the ways towards what you’re looking for but I won’t make any guarantees. For my part, I found devcards and figwheel amazing and love Reagent, but re-frame was the thing that made it go from “looks awesome and fun to use” to “I can make awesome stuff consistently and quickly”. If you want more details or anything like that, the #re-frame channel is active and helpful too.
In ClojureScript, I want some stuff generated in compile time, so I write a macro. This macro receive functions as it's arguments and return a map(not in syntax quote) after some computation. How can I parse function as arguments? I tried to write function in a cljc file, but still Could not Analyze <cljs form>
when call this macro.
@hwk the measure of a framework is how it helps you to bring regularity to bigger, more complex apps. Frameworks look like annoying overhead at small scale. So small little examples will show you nothing much. Over the last couple of years, I've had probably 10 people tell me "I started in pure reagent and I loved it, but my app got a little messy as my app grew bigger." That's where re-frame will help - it forces a bit more discipline/structure.
@doglooksgood Can you show us the macro you're trying to write? You only get symbols in the macro, you can't "parse" a function.
@mikethompson : Yeah, that's what I was assuming. That at some point, my devcard/reagent setup was going to "feel messy" and I'll suddenly realize "hmm, maybe this reframe thing makes sense"
@rauh I've made a minimal case, this is the macro:
(defmacro test-macro
[f]
(f))
And I write this function in a cljc
file.
(defn foo []
{:foo :bar})
The usage, require the cljc file in both clj(where macro is) and cljs file.
in cljs file:
(test-macro some.ns/foo)
@doglooksgood : what is the expected output of (test-macro some.ns/foo) ? -- and are you trying to infer it by (1) static analysis or (2) running the code ?
@hwk yeah those that praise re-frame the most are wrangling 40K lines of Clojurescript. :-)
That's when you need that discipline and structure.
the expected output should be {:foo :bar}, there's no syntax quote in my macro, because I want it run completely in compile time.
@mikethompson : the diagrams do look nice; I have been recently writing a poor man's datascript based off of http://aosabook.org/en/500L/an-archaeology-inspired-database.html
and the idea of "there is one source of truth -- the db, -- and all else is derived -- and all user actions just map to transactions on the db -- seem very very enticing"
@doglooksgood : so suppose you had the following code, what is it supposed to do (defn tricky [] (if [some machine halts] {:foo :bar} {:a :b})) in this case, what si your macro supposed to do?
Just return {:foo :bar} or {:a :b}, put the result in the place where the macro is called.
@doglooksgood Then you just need to eval it. (eval (f))
Actually, in my case, I'm try to write a DSL for generating stylesheet, this doesn't need any information from runtime. But the generating may take some seconds.
@rauh The eval works, but if I give some.ns an alias name, how can I correct resolve it?
@doglooksgood That's probably possible with tapping into the cljs compiler. But it's been a while since I did that 🙂
@doglooksgood (cljs/resolve-var &env sym)
, where (:require [cljs.analyzer :as cljs])
(test-macro `alias-ns/foo)
in macro, use
(defmacro test-macro [f]
(str (type (second f))))
this way, I can get the symbol.😂You could do this:
(defmacro cljc-eval
[sym]
((resolve (:name (cljs/resolve-var &env sym)))))
I have two question:
1. what is the full namespace of cljs/resolve-var
?
2. what's &env
stands for and how can I get it.
@doglooksgood You can just return it and see, there is also a bunch of info about it on google
Hello, I want to use macros in clojure script. But when I compile the cljs, the error Could not locate vr_secondview/devtools__init.class or vr_secondview/devtools.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
occurs. How do I define the compilation of the file devtools.clj?
@danielgrosse looks like your .clj
file is not on the JVM classpath
happens if you use something like src/cljs
and use cljs build tools to access it without telling lein
about it
@thheller That was the solution. Thank you
Should I be able to evaluate x
from the console when in the debugger? https://www.dropbox.com/s/vhq8osx3eg8jfl6/Screenshot%202016-11-18%2010.29.19.png?dl=0
@borkdude I think that'll only work in Dirac
but I'm not a devtools or dirac user, so can't really be sure
Ah, when I step through the debugger it works: https://www.dropbox.com/s/0yi7pkx7ufqv5y5/Screenshot%202016-11-18%2010.39.10.png?dl=0
Has someone experience with dirac, figwheel and cursive?
Hello @dnolen I load figwheel in cursive as it is documented on the wiki of figwheel. But I suffer on enabling dirac with it. At the first attempt I preload the dirac library and start figwheel with the plugin in terminal. But the dirac agent isn't enabled. On second I loaded (start-figwheel config) (dirac.agent/boot!)
. But dirac isn't connecting to the websocket.
@danielgrosse oh sorry, I thought you were just referring to cljs-devtools
@danielgrosse I should be able to help, but if you are a beginner, I would advise not using Dirac at this point
Hm, I know, figwheel is now only used as webserver and hot reloader. Dirac is providing a websocket which the chrome extension connects to. Am I right?
have you seen this document? https://github.com/binaryage/dirac/blob/master/docs/about-repls.md
here is an example of leiningen configuration profile matching the last picture: https://github.com/binaryage/dirac-sample/blob/bd25c762a379531045fe9062932d770d0efd7bfc/project.clj#L142-L168
as you can see, in the nREPL server JVM process, I start nREPL server, Dirac Agent and Figwheel sidecar, all happily sharing one JVM
after you get that working, here is the document describing how to connect with Cursive: https://github.com/binaryage/dirac/blob/master/docs/integration.md
@dnolen When I set a namespace into the preload setting. The namespace gets added to the cljs_deps.js, but when is it evaluated?
Atom users: I just stumbled over this, and it works with .cljs files too! https://atom.io/packages/atom-cljs-doc
@danielgrosse preloads come after the standard library but before all of your own code
@danielgrosse please share whole project.clj, from that error message it looks like you didn’t provide :figwheel-config
profile, which is a profile
I have seen 'in browser cljs repls' that depend on a clj server on the backend -- are there any "cljs repls" that run entirely in the browser ?
Is there a way to setup nginx as front-end reverse proxy to figwheel while using SSL for dev? I have an error connecting to wss:// so I've tried to use tunnels ruby gem. But I cannot map port 443 because it says it's already in use. So I'm kind of stuck.
@hwk yes that’s what bootstrap allows http://clojurescript.io
@dnolen : I just want to confirm: http://clojurescript.io/ is running entirely in my browser there is no server side compilation of any form going on?
@spacepluk we already have that optimization, it’s called :static-fns
in ClojureScript
I'm running some code on a very slow interpreter and I'm trying to find ways to make it a bit faster
@spacepluk if you’re looking for hotspots use Chrome DevTools profiling
I' using cljs. I'm using (println (.-stack e)). Now, my question is: is there a way I can interact with this output before it's written? In particular, I want to filter out certain stack traces.
@hwk if you mean you want to intercept evaluation - no there’s no generic way to do that
I want to filter for all strings in lst that contains *foo< so this should work right? (filter #(re-find #"foo" %) lst)
@spacepluk: I apologize. There was another part of my code which had (re-find #" ...") with no string.
cljs stack traces has too much cljs.core/js stack traces; I'm writing a filter to only display the ones from my actual code.
Thus, I'm filtering for "at <my-package-name>" in on a (map #(filter #"package-name" %) (split-lines (.-stack e))))
given you wrote clojurescript, om, om-next, and god knows what else, I'll keep it in mind 🙂
@hwk: chrome devtools have a feature called “script blackboxing”, look into that, many places where stacktraces are presented in devtools UI support that, including console stack trace printing
Two separate questions: 1) is there a guide on getting figwheel to work over google app engine, and 2) what is the standard way to deploy clj + cljs apps on gae ? [1] I'm assuming possibly not since, unless I use GCE and setup a VM, the clj is running on my desktop, but the website is served via GAE
@hwk 1) doesn’t make much sense to me - it is a general practice to develop app locally in a dev mode (using figwheel) and then build optimized version in advanced mode and deploy it - technically you could deploy a dev build on gae with "figwheel plugin” included and drive code reloading from your local machine, but for each hard refresh you would have to re-deploy a new version, sounds like a bad workflow
btw. I wrote this thing: http://firelogger.binaryage.com, it used to be pretty handy for server-side logging on GAE
darwin: 1) was not aware GAE even ezited 7 years ago; 2) you wrote a firefox addon for your own debuggin -- that's hard core; 3) I wanted to develop 'vs live database' -- but in retrospect, maybe it's better I don't do that
@br11k so you are trying to run figwheel as a server process? Ideally you'd use cljsbuild to compile the cljs and just serve that, figwheel is a dev tool.
@noisesmith I would like to use reload-less workflow using "lein figwheel dev". But I thought SSL would be working out of the box. I have been searching for this answer for quite a while and I'm really confused like what is the proper way to deploy apps written in ClojureScript
so you want to do live dev in a repl for your production environment?
you deploy clojurescript apps by using cljsbuild, then serving the resulting js files
after that it's the same as serving any other js
(I mean, that's the normal way to do it at least)
Not sure if I need REPL at all. I've tried using this guide to make it clear: https://solovyov.net/en/2014/cljs-start/
that's a dev workflow, it's not how you'd serve an app
I mean, figwheel might be just fine as a production server, but my assumption until I see proof otherwise is that it's fundamentally a security hole (as most dev tools are if clients access them)
br11k so you want nginx running in your dev environment? maybe I misunderstood
I already have a lot of applications running on my VPS, and :3449 port is not accessible for security reasons
figwheel should only be serving to localhost anyway, and the port is configurable
in my experience trying to access my app from other machines on the LAN doesn't allow the figwheel connection, which is sane (for security reasons, of course)
if you are using figwheel from docker I'd assume you could just tunnel the ports from the image into ports that work on your actual box
maybe I'm still misunderstanding this situation though
Yeah that is ok, I've also configured my nginx to serve files from resources/public folder so you can see it's working: https://cljs-todo.br11k.me/
There is a solution for this: https://github.com/bhauman/lein-figwheel/wiki/FAQ#what-about-https
oh yeah, you need the wss protocol
can't you just run wss over an alternate port? also, consider using ssh to tunnel the localhost-only websocket port from the server to your dev machine
that's at least as secure as wss, if not moreso
br11k my concern would be that since figwheel connects the js browser repl directly to a java process, someone could easily start messing with your server via their js console
because I don't think figwheel was written with security in mind, at all
So I've tried to change websocket port in project.cjl :websocket-url "<wss://cljs-todo.br11k.me/figwheel-ws>"
sure, but creating an ssh tunnel for the ws port might be less complex
But it gives me the error: VM884:35 WebSocket connection to '<wss://cljs-todo.br11k.me/figwheel-ws/dev>' failed: Error during WebSocket handshake: Unexpected response code: 200
ahh, we saw this with the websocket of our app (using nginx)
Yep I know how it works basically, but I'm not sure I would be able to map port 443 to another one
your case is close to the "connecting to a database behind a firewall" example on that page
but if port numbers are hard coded in the cljs, that makes it trickier
@br11k also my ops guy just found his config that fixed this for our server's nginx setup, I guess we can share that config if it helps
(I mean we were using this for our cljs websockets, not addressing figwheel at all, but I guess it would translate)
not even cljs - websockets and nginx
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 8083;
return 301 https://$host$request_uri;
}
server {
listen 80 proxy_protocol;
location / {
proxy_pass
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $proxy_protocol_addr;
}
access_log /var/log/nginx/elb-access.log elb_log;
proxy_connect_timeout 1202;
proxy_send_timeout 1200;
proxy_read_timeout 1200;
send_timeout 1200;
}
(edited)
what was the problem?
or, what worked?
awesome
When you told me that this is not the case, I've googled this: http://stackoverflow.com/questions/12102110/nginx-to-reverse-proxy-websockets-and-enable-ssl-wss and it's worked!