This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-06
Channels
- # architecture (25)
- # bangalore-clj (1)
- # beginners (21)
- # boot (45)
- # cljs-dev (38)
- # clojure (272)
- # clojure-austin (7)
- # clojure-finland (7)
- # clojure-france (3)
- # clojure-italy (7)
- # clojure-japan (1)
- # clojure-russia (13)
- # clojure-spec (36)
- # clojure-uk (31)
- # clojurescript (96)
- # core-async (15)
- # cursive (16)
- # datascript (3)
- # datomic (97)
- # emacs (107)
- # hoplon (16)
- # jobs (9)
- # keechma (1)
- # luminus (1)
- # off-topic (19)
- # om (39)
- # onyx (15)
- # pedestal (3)
- # planck (22)
- # protorepl (4)
- # re-frame (20)
- # reagent (3)
- # ring-swagger (25)
- # specter (26)
- # test-check (19)
- # testing (1)
- # untangled (381)
@eveko For adding lein to your build config, I will defer to the more knowledgeable people here. As far as how you are designing the backend: It isn't how I would do it, but for your school project it is how it is. I'm not intimately familiar with the terminology around the Java EE world, but as long as it exposes an API to the client you shouldn’t have any problems using reagent. (And I would recommend re-frame with reagent, for at least the reason that it will make explaining the design pattern used more succinct
Hi everyone. What's a good way to do Ajax calls, and how do you do the response on the server | ring side of things?
@sova cljs-ajax + ring-defaults + buddy for auth
We're starting a clojure course at my company. We're going to start with this Clojure MOOC http://iloveponies.github.io/120-hour-epic-sax-marathon/index.html and then move on to clojurescript and stuff related to analytics (so Datomic, Onyx, clojure in the cloud, etc..). Anyone know any interactive clojurescript courses, similar to the one I linked? We're probably going to build our own, but inspiration is always good.
kauko: I'm also writing an interactive clojurescript book http://langintro.com/cljsbook
@sova or just use Sente — it falls back to AJAX if necessary, but uses websockets by default.
How do I pass a function-reference to a macro?
Context:
If I hard-code ui.element.input/checkbox
into my macro, I’m able to exercise that specification. But if I send it as an argument to that macro using syntax-quote, it’s not able to resolve the spec
howdy folks! how might i go about adding the project.clj's version number as a property to my compiled javascript as part of the lein cljsbuild process?
What about embedding that in the app's HTML (`<script>APP_VERSION = 1.2;<\script>`) in the backend (you can obtain the number with (some-> (io/resource "project.clj") slurp edn/read-string (nth 2)
)
could do, not-raspberry! thanks for the suggestion. i'm trying to avoid the need for server side code at all though.
i'm closer but i seem to have a problem with clojurescript / closure compiler, specifically closure-defines: https://github.com/clojure/clojurescript/wiki/Compiler-Options#closure-defines when i try to compile my clojurescript i get the following error. it doesn't make sense to me. i'm obviously passing a string as a value to the key.
------ Figwheel Configuration Error ------
The key redgenes.core/VN at (:cljsbuild :builds :min :compiler :closure-defines) has a non-conforming value:
(str "some-version-number-test")
It should satisfy one of: Number | NonBlankString | boolean?
{:cljsbuild
{:builds
{:min
{:compiler
{:closure-defines
{redgenes.core/VN (str "some-version-number-test")
^---- The value at key redgenes.core/VN doesn't conform
}}}}}}
uhg, that's totally right. thanks dnolen. it even warned me when i quoted a key somewhere else.
gah. at the end of the day all i want is my project.clj's version somewhere within my cljs. maybe i can write a script to just append it to the compiled code, but that feels dirty.
someone over in #clojure linked me to this lein project and they seem to be doing it: https://github.com/jonpither/juxtweb/blob/d85b6443bbcd6b0202f150010816641f9feae28c/project.clj
okay, just to wrap up that mystery: i had (def version "0.1")
at the top of project.clj and in my cljsbuild options: ~version
in an attempt to unquote it. no bueno. so then i def'ed the version in a map (def props {:version "0.1"})
and tried ~(:version props)
and that worked just fine.
I'm going to replace the plain websockets in my hobby project for Sente, any reason I should not do this, or any pitfalls I might enter? The middle ware I use is compatible.
hi. I’m trying to hot-reload html imports (<link rel=”import”…) using boot-reload and not having any luck. works fine for plain old css and js, though. can figwheel or some other lib handle this?
@gklijs actually I wasn’t clear enough. I’m talking about an html import that contains polymer stuff e.g.
<dom-module id="headers">
<template>
<style> .... </style></template></dom-module>
just tried with plain old <style> as content, that didn’t work either. I’ll give figwheel a try, thanks.
@joshkh: it's not at all an elegant solution, but in the past I've used a two-step compile process on my CI server that first basically does lein pprint version
, then uses sed
to update a file that just has (def version "@@LEIN_VERSION@@")
in it, which is then followed by the normal lein cljsbuild
process
Never tried the lein-unquote thing with a :closure-define
, but that sounds like a better solution if you can get it working
hey, thanks @timgilbert !
Awesome
Probably a very basic question, but how do I load an ns and then use the updated def in the same repl statement? These work consecutively but not in the same statement: works
(require '[my.ns :as mns] :reload)
=> nil
(inc mns/const)
=> 2
doesn’t work (it does not reload the ns with the new definitions)
(do
(require '[my.ns :as mns] :reload)
(inc mns/const))
=> 2
out of curiosity, if you manually (inc mns/const) after the (do...) in the repl does it find const?
I’m solving this with a REPL action in cursive atm, but it would be neat not to have to do that
hrm, sounds like a bug
Maybe my workflow is strange, but wouldn’t this be a fairly common usecase when in the REPL? “Evaluate something, change a little code, evaluate it again"
I'm not too familiar with Cljs repls, but require
will trigger async file load which needs to be finished before the code using code from required ns can be read and evaluated?
@vikeri require
is a special thing, there’s no such thing as a dynamic require - it must be top level
Ok, I guess most editors have some macro (not the lisp kind) functionality and it can be solved that way if needed.
Another question, can I tell a REPL to start by evaluating a certain command? I would like my REPL to always (js/require “bootstrap.js”)
the first thing it does.
I’m using this one from the quick start:
(require
'[cljs.repl :as repl]
'[cljs.repl.node :as node])
(repl/repl* (node/repl-env)
{:output-dir "out"
:optimizations :none
:cache-analysis true
:source-map true})
@vikeri https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/repl.cljc#L922
repl
is just a wrapper for repl*
, which takes the options as kwargs instead of a map
@juhoteperi Alright, tried updating to
(require
'[cljs.repl :as repl]
'[cljs.repl.node :as node])
(repl/repl* (node/repl-env)
{:output-dir "out"
:optimizations :none
:init #(js/require “./myJsFile.js”)
:cache-analysis true
:source-map true})
But it seems the init function is executed by Clojure? Got this erro:
Exception in thread "main" java.lang.RuntimeException: No such namespace: js, compiling:
...
@vikeri You could consider putting any special initialization you want into a namespace and then have it required via :repl-requires
. See https://clojurescript.org/reference/repl-options#repl-requires
@vikeri Non-normative exposition if it helps: http://blog.fikesfarm.com/posts/2015-12-02-clojurescript-repl-auto-require.html
Is https://github.com/r0man/cljs-http the recommended way to make http calls using cljs?
@petr I've always just used the Xhrio utils that came with google closure (And therefore come with CLJS): https://developers.google.com/closure/library/docs/xhrio
@petr I’ve recently been using this library, which is a relatively 1:1 wrapper around Xhrio https://github.com/JulianBirch/cljs-ajax ; I used to use cljs-http but found certain limitations after a while; imo it’s always better to stick to less “decorated” libraries; in the end, you can always re-create the convenience in a few lines of core.async if you need to but also retain more power/control
Hiya ClojureScripters 🙂 Would anyone have ever tried to use a polyfill so (compiled) cljs code works better on more browser?
I can provide a example of a small project which currently behaves in a weird manner: https://piotr-yuxuan.github.io/1111101000-pieces/
I use css-transforms
and clip-path
, which are not properly supported on some browsers (works like a charm in Chrome Canary). Even when I try to add a polyfill from http://Polyfill.io <script src="https://cdn.polyfill.io/v2/polyfill.min.js"></script>
it still has a lot of issues
(disclaimer: I know cljs itself doesn’t have anything to do with compatibility issue, I'm just wondering if anybody has faced such troubles)
@piotr2b are you using advanced compilation? if so, probably you have a lot of missing externs for those polyfills
Thanks for your answer 🙂 but well, I thought any JS code (as minified as possible) will always talk to standard API through their standard names, won’t they? I’ve read that http://Polyfill.io relies upon user agent (so after compilation) to guess which definitions are to be sent.
@piotr2b there is no guarantee that whatever functions that service add are recognized by closure. Here is a list of stuff it knows about: https://github.com/google/closure-compiler/tree/master/externs/browser
@piotr2b to work around this, you can use pass a string to aget
, since that will not be renamed
or you can use a macro like this https://github.com/binaryage/cljs-oops
Sorry @isak , I’m afraid I’m not sure to get your point: I don’t understand why I should provide externs to Google Closure. If somewhere my (not optimized) cljs code use Array.Stuff (which need to be polyfilled), will the heavily optimised js produced by Google Closure shrink this reference? I think it won’t but I’ll be happy if you prove me wrong!
hi, desperate newbie question. I want to trigger "open file dialog" on an "input type=file" element via another button's "on-click" event. I have all the elements in the dom etc. I just struggle to find the right syntax/lib to manipulate dom to trigger what would be like "$input_el_id.click()" in jquery ? I'm using re-frame
@netroms I gonna get afk from some hours but send me a msg if you still need help, it will be a pleasure to help you 🙂
@isak same as above, I’m going to get afk for a couple of hours (aka night).
@piotr2b it is because you are using library functions that closure does not know about. Think about it -they aren't even in your build, they are fetched from a service. You might want to turn off advanced compilation for now, it is not something that "just works" https://clojurescript.org/reference/advanced-compilation
use https://github.com/binaryage/cljs-oops -- I started using it yesterday, it's awesome