This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-19
Channels
- # aws (4)
- # aws-lambda (2)
- # beginners (67)
- # boot (38)
- # cider (32)
- # cljs-dev (12)
- # cljsrn (2)
- # clojars (2)
- # clojure (190)
- # clojure-chicago (1)
- # clojure-dusseldorf (2)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (5)
- # clojure-russia (6)
- # clojure-spec (47)
- # clojure-uk (10)
- # clojurescript (59)
- # cursive (9)
- # data-science (14)
- # datomic (24)
- # devops (16)
- # emacs (8)
- # fulcro (25)
- # graphql (30)
- # hoplon (123)
- # juxt (15)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (6)
- # lumo (9)
- # off-topic (11)
- # om (7)
- # onyx (8)
- # re-frame (14)
- # reagent (5)
- # ring-swagger (5)
- # shadow-cljs (46)
- # spacemacs (41)
- # specter (8)
- # testing (8)
- # unrepl (31)
- # yada (18)
Hi, just wonder how to properly configure cljsbuild to handle loading of external libs which have non-js assets like stylesheets. I'm getting this parse error:
ERROR: JSC_PARSE_ERROR. Parse error. primary expression expected at /home/me/cljs-test/node_modules/m-react-splitters/lib/splitters.css line 1 : 1
@darwin Thanks! Seems like adding tools.reader as a deps was an okay solution for my case then 🙂
Is (.log js/console ...)
supported in a ClojureScript environments? (including bootstrapped CLJS, Planck, Lumo, etc). I'm in a situation where I can't use println
and the likes.
@val_waeselynck Sure, you can use it instead of prn println.
I follow https://clojurescript.org/reference/source-maps precisely, but Chrome will give me this:
Hey all! I tried to import a library (https://github.com/fulcrologic/semantic-ui-wrapper) into an om.next project.
My file is a cljc
file, not a cljs
so i run into the error:
>Could not locate fulcrologic/semantic_ui/factories__init.class or fulcrologic/semantic_ui/factories.clj on classpath. Please check that namespaces with dashes use underscores in the Clojure file name.
When i try to use reader conditionals like:
#?(:cljs [fulcrologic.semantic-ui.factories :as f])
#?(:cljs [fulcrologic.semantic-ui.icons :as i])
I get the error
>java.lang.RuntimeException: No such namespace: f
Because it still looks for the namespace on clj side.
Is dere a way to use this library in cljc anyway?Will adding more cpu's to a server decrease load average?
@arno what's your definition of "load average"? On the typical web server, adding more CPUs can reduce latency, but probably only marginal affect memory usage.
Actually I managed to use the semantic-ui library now - but i needed an additional reader conditional around each semantic ui element on the page. So my next question would be if there is a way around having to use the reader conditional for every usage of a semantic-ui element
Extract the functions that use js-only stuff into separate .cljs
namespace, and implement .clj
namespace with the same name that has only dummy versions of the same functions.
For instance, in foo.cljs
:
(ns foo
(:require [goog.object :as o]))
(defn oset!
[obj k v]
(o/set obj k v))
And in foo.clj
:
(ns foo)
(declare oset!)
From bar.cljc
you can now require foo
and use oset!
without a reader conditional.@alpox Does this make any sense? I’ve managed to remove much boilerplate reader conditionals using this pattern.
@U06BEJGKD That sounds itself like a lot of boilerplate though. Wouldn’t the library have to do that instead of me for every function in the library?
Well, yes, I agree, but you provide the boilerplate only once, in one place, for your third-party library. In your consuming components there is absolutely no boilerplate.
Hmm so for each function in the library i’d have to make a single entry in two files each?
@val like, on linux server uptime, load average
by how much can adding more cpu reduce latency?
There just is no generic answer to that, I'm afraid. Try first to determine wether your workload is CPU-bound, memory-bound, or IO-bound (for most web servers, it's the 3rd option).
@lovuikeng I don’t think the problem is connected to om
ok, cool
Hi, I have created an issue with proposal and a question for my first ClojureScipt patch, maybe someone with knowledge about how node.js specifics are implemented can give me feedback https://dev.clojure.org/jira/browse/CLJS-2386
I’m trying to use the buffer npm package from clojurescript and I’m getting a really strange error in .toString(‘base64’) where it’s returing NaN and undefined instead of the actual base64… ‘hex’ is working though… really hard to track that down
dev-frontend:cljs.user=> (require '[buffer :refer [Buffer]])
nil
dev-frontend:cljs.user=> (new Buffer "0")
#object[Object 0]
dev-frontend:cljs.user=> (.toString (new Buffer "0") "base64")
"undefinedundefined=="
dev-frontend:cljs.user=>
well - it’s from a lower-level requirement…
(require '[base64-js :as b64])
nil
dev-frontend:cljs.user=> (.fromByteArray b64 (new js/Uint8Array [0 1]))
"undefinedundefinedundefined="
this may be neither here nor there but CLJS comes with goog.crypt.base64
@pesterhazy that’s probably a good call as a workaround
I'd try it from the node.js repl first (in JS), then lumo
node works…
> var b64 = require('base64-js');
undefined
> new Uint8Array([0,1])
Uint8Array [ 0, 1 ]
> b64.fromByteArray(new Uint8Array([0,1]))
'AAE='
lumo works too
cljs.user=> (require '[base64-js :as b64])
nil
cljs.user=> b64
#js {:byteLength #object[byteLength],
:toByteArray #object[toByteArray],
:fromByteArray #object[fromByteArray]}
cljs.user=> (.fromByteArray b64 (new js/Uint8Array )) 1]
"AAE="
this is confusing though…
(goog.crypt.base64.encodeString (new js/Uint8Array [0 1]) false)
"MCwx"
(defonce cref (r/atom nil))
(defn home-page []
(r/create-class
{:component-did-mount
(println "mounted" @cref) ; nil
:component-did-update
(println "updated" @cref) ; nil
:reagent-render
(fn []
[:div {:style {:display "flex"
:justify-content "center"
:flex-flow "column"}}
[:h2 {:style {:text-align "center"}}
"Welcome to GAME OF LIFE"]
[:canvas {:height 450
:width 450
:style {:border "1px solid black"}
:ref (fn [el]
(do
(reset! cref el)
(println "nooo" @cref)))}]])}))
how do I access dom ref?
I am getting nil in component-did-mountwhere do you define cref?
also it should be #(println ...)
. rookie mistake! 🙂
fn call v creating an anonymous fn
it happens to the best of us