This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-21
Channels
- # beginners (82)
- # bitcoin (1)
- # boot (38)
- # cider (6)
- # cljs-dev (13)
- # cljsrn (5)
- # clojure (320)
- # clojure-italy (22)
- # clojure-losangeles (6)
- # clojure-russia (55)
- # clojure-spec (25)
- # clojure-uk (48)
- # clojurescript (64)
- # component (16)
- # core-async (6)
- # cursive (54)
- # data-science (2)
- # datascript (2)
- # datomic (8)
- # docker (1)
- # ethereum (1)
- # fulcro (1)
- # garden (1)
- # graphql (16)
- # heroku (6)
- # hoplon (12)
- # jobs (4)
- # juxt (1)
- # leiningen (9)
- # off-topic (39)
- # om (13)
- # om-next (2)
- # onyx (9)
- # pedestal (2)
- # portkey (12)
- # re-frame (25)
- # reagent (6)
- # ring-swagger (4)
- # schema (1)
- # shadow-cljs (10)
- # spacemacs (11)
- # testing (19)
- # uncomplicate (1)
- # unrepl (6)
- # vim (21)
- # yada (3)
I ended up just storing it in firebase, but the question was as to whether I could just deploy a JSON file alongside by html and css (this is for a prototype app) and require it just using cljs (rather than having to fetch the data)
@conaw, you would create a macro that's basically (defmacro include-file [path] (slurp path))
and when you call it from ClojureScript, it expands to a string that contains the contents of the file at the compile time.
which may destroy your data but definitely will make everything slower depending on the amount of data you are working with
In a clj/cljs app I'm building I'd like to split some parts into separate pages instead of bundling all of the client side code into one single page app. For example the registration, it doesn't make a lot of sense to have that code bloating the main app. Is there a way to tell the compiler to build parts of the app as separate cljs "sub-apps"?
just use XHR to load the file on load. the initial .js
load will be faster, the .json
is loaded async and is cacheable
filesize is the problem. as it will become size of .js + size of .json. so if you have a 2mb .json file the browser will do a blocking load that takes forever if inlined into your .js
@vinai :modules
is what you are looking for, it splits the code based on the namespaces you provide
java.lang.NullPointerException
at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
at java.util.regex.Matcher.reset(Matcher.java:309)
at java.util.regex.Matcher.<init>(Matcher.java:229)
at java.util.regex.Pattern.matcher(Pattern.java:1093)
at clojure.core$re_matcher.invokeStatic(core.clj:4801)
at clojure.core$re_matches.invokeStatic(core.clj:4831)
at clojure.core$re_matches.invoke(core.clj:4831)
at cljs.util$compiled_by_version.invokeStatic(util.cljc:42)
at cljs.util$compiled_by_version.invoke(util.cljc:39)
at cljs.closure$compile_from_jar.invokeStatic(closure.clj:578)
at cljs.closure$compile_from_jar.invoke(closure.clj:571)
and how to debug it, I tried adding the :verbose compiler option but it doesn’t output anything more
oh, it looks like it’s trying to determine if a compiled js file has the same version as the current version…. removing all generated js files fixed the issue
is this expected?
ui.core> (first (:responses @app-state))
#object[XMLHttpRequest [object XMLHttpRequest]]
ui.core> (object? (first (:responses @app-state)))
false
this seems better alternative
ui.core> (instance? js/Object. (first (:responses @app-state)))
true
what is that .
doing there?
it looks like object?
is really checking for what on the jvm we'd call a PoJo
cljs.user=> object?
#object[Function "function (a){return null!=a?a.constructor===Object:!1}"]
if the constructor wasn't Object, it will return false
"plain old java object"
in other words, it's got nothing special, in clojure we'd just use a hash-map
if Object was the constructor, it's not an instance of anything interesting (though of course being js it could still be or do anything at all)
json is a string format - but when you consume it you get Object instances
Have anyone encountered the following error when compiling in advanced mode (clojure 1.9.0-beta1, cljs 1.9.908)?
.../cljs/core.js:3579: ERROR - Parse error. primary expression expected
case ##Inf:
@honzabrecka look into #cljs-dev, it was discussed there
I guess I need to look at objects differently, thought they all were keys connected to values or functions and hence, all the same.
If the constructor was Object, you know it's not "special" and I assume there are cases where that matters. For example, if the constructor was Object, you could use goog.object
to list and iterate keys etc. and not run into the gotchas that you would with weirdly behaved things like the DOM that are almost well behaved but... not.
normal js libs use Object like we do hash-maps
ok, can this be seen in cljs when the return value is #js {:key "val"}
as opposed to #object[]
?
I hope someone else can give you an answer for that, but - sounds plausible to me
ERROR: JSC_PARSE_ERROR. Parse error. primary expression expected at /Users/.../target/cljsbuild-compiler-1/cljs/core.js line 3579 : 6
yes, read above -- this is caused by a change in how 1.9-beta1 prints infinity/nan, i believe there's already a fix in CLJS's jira
Is there an alternative version of hash that is consistent between clojurescript and clojure?
Consistent as far as (hash 1) in clj being equal to (hash 1) in cljs. I'm using the hash to generate a css class name, but I didn't realize integers weren't hashed in the same way.
https://github.com/arachne-framework/valuehash is probably portable to cljs