This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-20
Channels
- # architecture (25)
- # beginners (68)
- # cider (10)
- # clara (3)
- # cljs-dev (90)
- # cljsrn (16)
- # clojure (132)
- # clojure-austin (7)
- # clojure-berlin (3)
- # clojure-czech (1)
- # clojure-dusseldorf (1)
- # clojure-greece (5)
- # clojure-italy (39)
- # clojure-spec (5)
- # clojure-uk (78)
- # clojured (2)
- # clojurescript (92)
- # community-development (6)
- # cursive (7)
- # data-science (1)
- # datascript (14)
- # datomic (32)
- # duct (8)
- # emacs (5)
- # figwheel (3)
- # fulcro (47)
- # hoplon (12)
- # jobs (10)
- # luminus (16)
- # lumo (5)
- # off-topic (1)
- # onyx (2)
- # parinfer (47)
- # pedestal (6)
- # re-frame (10)
- # reagent (2)
- # reitit (61)
- # ring (8)
- # ring-swagger (16)
- # shadow-cljs (116)
- # sql (17)
- # utah-clojurians (2)
- # vim (1)
@mfikes Big thanks for the help, looks like it was an issue with including the macro wrong. I’ll keep looking into it
i want to write a function that returns true if the argument is an ordinary JS object, and false if it is a clojure collection, records or type
satisfies? ISeqable
would be a good approximation...?
Hello folks, I have a potentially silly question about cljs/js data structure interops. Right now the main pain point using ReactNative is remembering which component is a vanilla js one and which one is a cljs component, so there's a lot of clj->js and #js involved and a lot of confusion.
I saw this gist from dnolen about using ImmutableJs instead of cljs data structures https://gist.github.com/swannodette/436196e9d22a5164f837 Would this solve the clj->js interoperability problem? If so, is there a way to compile a forked version of ClojureScript that uses ImmutableJs whenever we create literal map, lists and arrays?
I'm happy to pay the performance problem to add developer convenience here, and I'm sure many others would do. The nice thing of clojure on java land is the seamless data structure interop.
Another crazy idea: adding destructuring for vanilla js objects would be great
@frankie I would ask this question in the #react-native channel, in the browser at least this kind of a solved problem as HTML components are so uniform
Yes, cljs on the browser is mainly a solved problem because components are already quite functional. The problem with RN and libraries like react-navigation is having to pass components (written in cljs) as arguments that are going to be called with js args
The typical example is a react ListView that takes a renderer (a simple cljs function) but it will call the renderer passing in a js map (so no chance to use destructuring)
I will ping the react-native channel too but I already know most of the current solutions, which are not satisfying
That's why I wondered if there's something that can be done at the language level
I was wondering if there's a js interface that can be implemented by cljs data structures to ease interop
it would be pretty neat to have a js interface to cljs structures. this does pop up on the browser sometimes when using callback oriented higher order functions like react-dnd
@frankie not sure about the performance/ImmutableJs, know to little about js for it. But I do like to keep the js stuff in separate namespaces as much as possible to avoid confusion. Maybe put vanilla js and cljs components in a different namespace will solve some of the confusion?
Not really, in the ReactNative world js and cljs component have to interact with one another quite frequently
The typical example is a react ListView that takes a renderer (a simple cljs function) but it will call the renderer passing in a js map (so no chance to use destructuring)
Anything under react-navigation is quite awkward to use if you don't rely on implicit js transformation done by e.g. reagent
why not wrapping ListView (and the other components)? in your wrapper you could call the renderer passing a cljs map
@U5LPUJ7AP sure, but then you have to maintain wrappers to all React components, which are numerous and because it's js land, change quite frequently from one version to the other
Plus, there's no standard way of wrapping them (because of the fragmentation of om, reagent and rum) so it's likely the effort one does to wrap them for reagent it's useless for rum users etc.
just choose one and the others can use the reagent/adapt-react-class
equivalent
that only really helps if you fix the callback. the point is every time you use one of these callback-style interfaces (which exist in dom land too, btw), you end up having to write a call back that deals with js data in a very confusing way. i’m not sure it is solvable, really. i don’t see how wrapping helps.
(defn ListView [renderer]
(js/ListView #js{:renderer #(clj->js (renderer (js->clj %)))}))
(defn example-renderer [v]
;; v is clj, return value is also clj
)
same for DOM, wrap the fn
Easy in theory, now write me a wrapper for this https://facebook.github.io/react-native/docs/flatlist.html
same principles apply, the first one just needs a JS object (`clj->js` will do) and a function that returns a React element (use reagent/as-element
or whatever you have)
likewise, I wrote a wrapper for ReactDOM.unstable_renderSubtreeIntoContainer
in Om Now, no problems whatsoever. this is a non-issue
Are there any obvious things I should look for when debugging a build of 3 files that takes > 90 seconds?
@alex-dixon you could check for weird top level actions in the compile time code
When I turn on verbose I don’t see any console output for the majority of the 90 seconds…
@alex-dixon is a performance issue you want to debug? Have you tried :compiler-stats true
?
Seems related to cljs 1.9.946
@richiardiandrea Seems like a bug or I’m doing something really wrong. I used complier stats and it outputs time info at the end…not sure if it’s supposed to yield more than that
It yields time for each namespace iirc
It’s a build for a webworker. Not sure if that matters
Oh, that is something I have never used so I can't suggest anything more sorry 😄
As far as I know I’m just building a js file that will be workerized though. I can’t see where anything is worker-specific
@alex-dixon I guess since this is cljs there’s no chance that some top level js is getting run in the build chain?
There could be I think. I’m trying to use cljs in a worker with a react frontend, so I have a srcjs folder and a node_modules folder in the top level of the project
As far as I can tell the cljs build config isn’t referencing it though
in that case, you could double check that you don’t do anything inside def
Hm ok. Well it compiles in 15 sec on 1.9.854 but ~90s with 1.9.908 or 1.9.946
… interesting! you might have found a bug
In another project with more node_modules downgrading the cljs version made the build go from 240s to 80s. I still think that’s high because I’m only trying to compile ~50 lines of cljs 😕
I’m willing to file a bug even though I’ve no idea what’s really going on
@alex-dixon :compiler-stats true
+ :verbose true
maybe you just need the new feature to ignore node_modules
completely - that will be in the next release or if you’re using deps.edn
you can leverage it now
Hi, who could advice a good book where all build tools (like externs, bundling, leiningen plugins, and working with npm and webpack) . Trying to solve a problem with externs... just need some RTFM 🙂
@faxa I’d use the clojurescript project wiki on github as the primary source of information, leiningen is an automation tool and the lein plugin just provides an integration with build processes
I just tried to build my CLJS project with lein-cljsbuild "1.1.7"
after I accidentally introduced a circular dependency. I hang up without any warning. Is it just me, or was it failing the build before when it encountered circular dependencies?
@alex-dixon If the compiler gets "stuck" in a spot for a good 90 s, one thing you can do is kill -3
on the compiler process ID, and that will produce a thread dump and we can see what it is doing at that point in time.
is that the same output you would get with jstack?
@noisesmith Yes, evidently so. kill -3
causes the results to go to stdout
of the signalled process, while jstack
appears to fetch the same info and dump it to its own stdout
. 👍
@mfikes Thanks. Will try as soon as I’m done with work. Hopefully sooner 😅
So I've spun up a project using lein new reagent todo, when I'm in the repl from lein figwheel the arrows keys don't work they just print chars. Any work around this?
@joelv try rlwrap
https://github.com/bhauman/lein-figwheel#using-the-clojurescript-repl
newer versions of figwheel have their own readline wrapping built in - it's still experimental though
Oh there is also this super spiffy experimental thing but I don’t know if it works with your setup https://github.com/bhauman/rebel-readline I haven’t messed with it yet since I find the repl frustrating
@lee.justin.m yeah - the latest figwheel snapshots actually use that repl
I need to do some vanilla application/x-www-form-urlencoded
post request. Is there a way to do it programatically from cljs/js, this is my attemt so far, it's sending a payment request to an payment api
(defn pay-request [env]
(let [form-data (new js/FormData)]
(doseq [k (keys env)]
(.append form-data (name k) (str (k env))))
(js/fetch ""
#js {"method" "POST"
"headers" #js {"Content-Type" "application/x-www-form-urlencoded;charset=UTF-8"}
"body" form-data})))
but from the network panel in devtools I can't see any registration of form data being present. Quite lost.despite being in re-agent, I'd want the redirection to take place that this endpoint provides. (it's their test endpoint actually)
@hlolli in terms of your CLJS translation, there is nothing obviously wrong to my eye, but this github issue suggests that the fetch api doesn’t let you override the encoding type when you pass it a formdata https://github.com/github/fetch/issues/263
oh the FormData class seems to not to be what I'm looking for, but URLSearchParams.. try that
you might try this DIY approach https://stackoverflow.com/a/37562814/4771768
typical Iceland, useing 20 year old technology for everything (not useing json api 🙂 ), their job offering are usually "ASP/NET is the new hot stuff".
I'm overthinking it, React has support for forms https://reactjs.org/docs/forms.html
Here's me, misunderstanding ClojureScript and Node at the same time. Thoughts anyone? I've got a submodule of JSON files in a resources
directory, I'd like to load them as maps, but so far as I know there's no equivalent of
function in ClojureScript:
ohwait, maybe I should be using http://lumo.io
(:require ["fs" :as fs]) .... (let [file-contents (fs/readFileSync "file.txt")] .. do stuff
I think they are going to deprecate the nonsync fs functions, some already have been I read recently.
That method of requiring doesn't appear to work--- I'm using lumo, I'm really fuzzy on how lumo/planck differs from "straight" cljs in this regard