This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-31
Channels
- # admin-announcements (1)
- # beginners (1)
- # boot (91)
- # cljs-dev (11)
- # cljsjs (8)
- # cljsrn (38)
- # clojure (89)
- # clojure-dusseldorf (1)
- # clojure-russia (6)
- # clojure-spec (14)
- # clojure-uk (4)
- # clojurescript (25)
- # data-science (1)
- # datascript (3)
- # datavis (4)
- # emacs (25)
- # events (1)
- # jobs-rus (3)
- # off-topic (1)
- # proton (3)
- # re-frame (19)
- # reagent (5)
- # specter (10)
- # yada (1)
Hi! I was wodering if it's possible to do destructing on JS objects, my naive approch didn't work:
(let [{x :x} {:x 1}] x)
; => 1
(let [{x :x} #js{:x 1}] x)
; => nil
@pesterhazy: Thanks for the tip. I guess I’ll try managing stuff through npm manually then. 😃
hmmm... alright thanks~
would be nice if I could do destructing in JS callback functions and save a line, but I guess not.
the ES2015 folks just loves doing this in callbacks:
({someKey}) => ...
Yes, I'm pretty new to ClojureScript, and coming from TypeScript / ES6 the new flavors of JS support destructuring JS/JSON objects
not sure which callback functions you refer to but I guess I wonder why you wouldn't be able to use the CLJ data structures instead
if it's a JS object and you only need 1key you can do something like this for an anon function, #(some-func (.-someKey %))
e.g. a callback i use in a component for on-change
is #(reset! value (-> % .-target .-value))
It's an event handler from a 3rd party JS library and they are passing me some JS data structures. my function is a bit long (ajax calls) so I didn't use the function literal
@akiroz I think you want something like this then `(def data #js {"myProp" "a value" "anotherProp" "a second value"}) (let [{:strs [myProp anotherProp]} (js->clj data)] ....)`
is there a lib you would recommend for doing get and post requests with json, and saving cookies etc?
not sure about react native but I'm using cljs-ajax
with promesa
for async requests and reagent-utils
for various things.
if react native offers the same APIs as browsers then it should work fine (I've never used react native before)
https://github.com/funcool/httpurr is also an option 😉
@pvinis: cookie are kept automatically by the react-native runtime, just like in the browser
at least on ios, but pretty on android too
cljs-ajax is awesome on rn