This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-08
Channels
- # architecture (8)
- # beginners (78)
- # boot (20)
- # cider (81)
- # clara (53)
- # cljdoc (10)
- # cljsjs (3)
- # clojure (55)
- # clojure-boston (1)
- # clojure-dev (25)
- # clojure-nl (3)
- # clojure-uk (65)
- # clojurescript (65)
- # core-async (1)
- # cursive (41)
- # data-science (4)
- # datomic (16)
- # editors (74)
- # emacs (17)
- # events (1)
- # figwheel (3)
- # hyperfiddle (39)
- # immutant (16)
- # jobs-discuss (62)
- # juxt (2)
- # keechma (2)
- # leiningen (6)
- # mount (7)
- # nrepl (1)
- # off-topic (30)
- # onyx (14)
- # protorepl (2)
- # re-frame (4)
- # reagent (15)
- # reitit (19)
- # shadow-cljs (102)
- # sim-testing (1)
- # spacemacs (44)
- # specter (15)
- # tools-deps (50)
- # vim (2)
having your code in .cljc files and rendering it server-side (then hooking up the React logic in the client side) is super easy in rum. last time I checked that was tricky in reagent, but that may have changed
When you say "rendering it server-side" what do you mean? To render a js file specific for a user? Or to render a html specific for a user (like Rails, for instance)?
Usually, you generate a bundle with your cljs files and this files is served for all your users, right? And this client code performs requests fetching the data it needs :thinking_face:
I think they were referring to server side rendering (as described in https://reactjs.org/docs/react-dom-server.html)
anyone know of a solid & fast shallow implementation of converting a JS data structure to CLJS?
@lilactown I copied js->clj
- I know....
I think the go to though for big objects is to use transit
. It would be handy to have an option for shallow transform so that we don't need to add a dependency
@lilactown something like this?
(defn js-obj->hash-map
[o]
(let [t (transient {})]
(-> o
(goog.object/forEach (fn [v k] (conj! t [k v]))))
(persistent! t)))
(defn js-array->vec [a]
(vec a))
I noticed this exception in a cljdoc build and it seems that the analyzer’s ns validation somehow chokes on this ns form: https://github.com/dvingo/cljs-styled-components/blob/59d865294e4b99490a318469fa56722c5ae1a726/src/main/cljs_styled_components/reagent.cljc#L1-L11 Is that expected? (Is the ns form not correct?)
@pesterhazy that is "illegal". transients should still be used like persistent data, meaning you should not call conj!
multiple times on the same thing, rather always use the return value.
@martinklepsch looks like someone published something I advised against. it is supported in shadow-cljs but not CLJS. See https://dev.clojure.org/jira/browse/CLJS-2376
So that :default
thing is shadow-cljs specific and (usually) shouldn’t be published in jars?
@thheller fine
(defn js-obj->hash-map [o]
(let [a #js [(transient {})]]
(-> o
(goog.object/forEach (fn [v k] (aset a 0 (conj! (aget a 0) [k v])))))
(persistent! (aget a 0))))
What's the actual implementation of >
?
The source doesn't make sense per se and obviously is using some trick
(defn ^boolean >
...
([x y] (cljs.core/> x y)))
@vemv it is implemented as a macro in cljs.core but you can totally define your own >
@thheller could you point out to the macro location? I'm interested in how it works as I'm debugging an issue
I am currently looking at mori vs immutable.js, and thought about building an OO wrapper around mori, to make the API look more like Immutable.JS, and ES6 for that matter. And I stumbled upon the major difference (in my oppinion) between the APIs that the two expose, namely the (lazy) Sequences. So, for instance map
on a HashMap
will return another HashMap
in immutable.js, while it returns a (lazy) sequence in mori (and clojurescript, of course). It's quite an interesting design decision, and I wonder whether that's the reason why mori is faster. Anyway this means, that in order to do the same in mori/clojurescript I need to build another hashmap from the resulting sequence, which will require two "iterations". For this reason I gave up on the OO wrapper around mori. I will do some performance tests at some point, to verify my suspicion, but I'd like to hear your thoughts on this. One question that pops into my mind is how many times will you actually convert the sequence from a map
over hashmap back into a hashmap vs just process it further.
hi guys
how can i move to the beginning of the page in clojurescript ?
yeah in the dom
clojurescript function to goto beginning of the page, say :on-click #(here)
Can't remember the exact details. But find the global scroll on the window and run js-keys
on it to see what props it has. It might have a top
or a y
and then just set it to 0
.
(.scrollTo js/window 0) ?
it didn't work
i tested it
@john how works?
hi guys
why when i use secretary routes and refresh page i get "404 page not found" ?
or the state of reagent atom gone when i refresh the page?
and how can i fix this issue?
just def
I'm not a clojurescript expert, but I think the namespace gets reevaluated on reload. So def's are re-def'd to their original states.
so what is the normal ways to handle this situation ?
how can i handle with refresh page?
maybe save to session ?
@abdullahibra what are you trying to save between page refresh
when you refresh the page, all JavaScript code is re-run. any state from before is gone.
i have current page variable which is reagent/atom i save on it the current reagent function
when i refresh it it gone to the default
how can handle keeping state even after refresh ?
add vars to session ?
so you want the user to be able to come to your application, change pages, and if they refresh it will go to the page they left off?
then yes, saving something to the user’s session storage is probably the right thing to do
@abdullahibra the 404 is probably happening because you don’t have your server setup to redirect all client-side routes to serve up your main bundle. if you serve the app out of /app
and then you navigate to /app/user/info
and then hit refresh, the browser will go hit that location on the server. you’ve got to get your server to handle that. shadow-cljs’s dev sever has a “push state” feature to handle this during development. i don’t know how people deal with this using figwheel or whatnot