Fork me on GitHub
#clojurescript
<
2017-10-11
>
ThadIsNOTFood02:10:17

I have a nested json data structure that isn't being decoded. Only the first level is being decoded and it leaves the maps coded as js json.

(let [sales-results (js->clj (.parse js/JSON (-> data :results :sales-results)) :keywordize-keys true)]
result:
[{"type":"SalesOrder","createdfrom":"","statusref":"pendingApproval"......
What have I done wrong?

tomaas08:10:46

hi, using matchbox library from clojure code works well if firebase permission write = true. However, server code is supposed to use path/to/serviceAccountKey.json file to have permissions to write. Has anyone used this with matchbox, and if yes, how?

Bravi09:10:48

what is a recommended way to deal with css in clojurescript?

tobowers09:10:45

I’ve been using lein-sass

tobowers09:10:14

I have an npm dependency that does this:

try {
        var expo = require("expo");
    } catch(e) {
        console.log("expo is not defined, using internal guid");
    }
That makes clojure ignore the entire dependency because it can’t find “expo.” Is there someway to ignore the error?

mseddon09:10:25

I've been using https://github.com/noprompt/garden, great if you want to do hiccup like css generation.

tomaas10:10:37

new FirebaseOptions.Builder()

tomaas10:10:51

i rewrite this (new (.-Builder FirebaseOptions)) in clojure. What am I doing wrong?

tomaas10:10:38

I get Unable to resolve classname: (.-Builder FirebaseOptions)

sundarj11:10:23

is it a js variable? you might need to do js/FirebaseOptions

tomaas11:10:00

no it's in java. I have (:import com.google.firebase.FirebaseOptions)

tomaas11:10:12

so FirebaseOptions is in scope

tomaas11:10:56

oh sorry for posting this in this channel

sundarj11:10:41

try (new FirebaseOptions$Builder)

joshkh11:10:40

given that cljs-http returns channels, how might one go about waiting for a collection of requests to complete before proceeding? such as mapping post over a few URLS and collecting the results into a single, realized collection?

tomaas11:10:59

@sundarj, still the same issue

sundarj11:10:45

@tomaas maybe it's a static field: (new FirebaseOptions/Builder), and that's the extent of my interop knowledge i'm afraid

tomaas11:10:03

@joshkh something like this?

tomaas11:10:27

@sundarj , tried this too but also does not work

tomaas11:10:10

thanks anyway

joshkh11:10:56

@tomaas close but not quite there. that's taking from each channel and calling a function with the results, but it still doesn't know when all requests have been completed

joshkh11:10:17

i'm trying to end up with something like this (!> single-result-channel [body1 body2 body3])

tomaas11:10:19

They are completed after the doseq expression does its job

joshkh11:10:30

yes but doseq returns nil, so i can't map or reduce over the results taken from the channels in one go. 'do-something' will be called individually for each get request and won't have awareness of the other responses. (sorry, i'm not yet totally comfortable with channels)

tomaas11:10:33

maybe, smth like this then 🙂

joshkh11:10:09

haha that was my first reaction but using a stateful atom felt dirty

joshkh11:10:49

anywho i found a working example here, half way down under the section "Returning Values in Order" http://clojurescriptmadeeasy.com/blog/promises-with-core-async.html

joshkh11:10:27

(defn into [coll & chans]
  (go-loop [coll coll
            chans chans]
    (if (seq chans)
      (recur (conj coll (<! (first chans)))
             (rest chans))
      coll)))

sachinharpalani11:10:31

I am trying to interop a High Order Component used in https://github.com/okgrow/react-native-joyride. The code for HOC is:

export default joyride()(App);

class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <JoyrideStep text="Hey! This is the first step of the tour!" order={1} name="openApp">
          <JoyrideText style={styles.title}>
            Welcome to the demo of
            {'\n'}
            "React Native Joyride"
            </JoyrideText>
        </JoyrideStep>
        <View style={styles.middleView}>
          <JoyrideStep text="Here goes your profile picture!" order={2} name="secondText">
            <JoyrideImage
              source={{ uri: 'https://pbs.twimg.com/profile_images/527584017189982208/l3wwN-l-_400x400.jpeg' }}
              style={styles.profilePhoto}
            />
          </JoyrideStep>
          <TouchableOpacity style={styles.button} onPress={() => this.props.start()}>
            <Text style={styles.buttonText}>START THE TUTORIAL!</Text>
          </TouchableOpacity>
        </View>
        <View style={styles.row}>
          <JoyrideStep text="Here is an item in the corner of the screen." order={3} name="thirdText">
            <JoyrideText style={styles.tabItem}>
              <Ionicons name="ios-contact" size={40} color="#888" />
            </JoyrideText>
          </JoyrideStep>

          <Ionicons style={styles.tabItem} name="ios-game-controller-b" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-globe" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-navigate-outline" size={40} color="#888" />
          <Ionicons style={styles.tabItem} name="ios-rainy" size={40} color="#888" />
        </View>
      </View>
    );
  }
}
Im trying this :
(def JoyRide (js/require "react-native-joyride"))
(def joy (r/adapt-react-class (.-joyride JoyRide)))
(defn home-page []
[joy (r/reactify-component
            [JoyrideStep
             (clj->js {:text "FIrst step"
                       :order 11
                       :name "openApp"})
             [JoyrideText
              "Welcome to the demo"]])]

(def pages
  {:home #'home-page
   :phone #'phone-page
   :pay #'pay-page
   :video #'video-page
   :intro #'intro-page})
I am not a valid react class. Can someone help me?

tomaas11:10:05

@joshkh, nice, a clean, not-stateful solution 🙂

sachinharpalani12:10:10

@lovuikeng i refactored app-root function (https://stackoverflow.com/questions/45909731/react-hoc-wrapping-with-clojurescript-and-reagent) to this:

(defn app-root []
  (let [m (-> [(pages @(subscribe [:get-page]))]
              r/reactify-component
              joy
              (r/adapt-react-class))]
    [m]))
I am still getting the issue : Component(...):A valid react class must be returned

lovuikeng12:10:29

there is no need for r/reactify-component since joy itself is already a react component, correct?

sachinharpalani12:10:13

@lovuikeng the

r/reactify-component
is for
[(pages @(subscribe [:get-page]))]
because to my understanding HOC is a function that takes React Component as input and outputs a new React Component

sachinharpalani12:10:27

@lovuikeng Also i removed r/adapt-react-class to joy

(def joy (.-joyride JoyRide))
since i am anyway using adapt-react-class in macro

sachinharpalani12:10:57

@lovuikengI am actually working on react native app

sachinharpalani12:10:08

facing difficulty in export default joyride()(App);

lovuikeng12:10:11

sorry, @sachinharpalani I speak only clojurescript 😞

sachinharpalani12:10:50

@lovuikeng Its okay, i apologize i didnt mention that earlier 😞

lovuikeng12:10:45

you might want to try npm channel

rnagpal14:10:23

Simple data representation question. How do you represent your data returned from Ajax calls. Req 1) We should be able to show loading when data is fetched 2) We should be able to show error if it errors 3) We show the data when available I prefer the following structure

{
 :in-process false
:data nil
:has-errored true
:error "InvalidRequest"
}

rnagpal14:10:40

Any better recommendations ?

souenzzo15:10:41

binaryage/cljs-devtools formatters now works on firefox 57+ (but still says that dont work 😛 )

darwin16:10:40

@souenzzo I will look into that, I wasn't aware that Firefox was about to implement support for custom formatters

darwin17:10:55

@souenzzo: why do you think it should work? I'm looking at https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Custom_output and there is no mention of support for chrome's custom formatters (aka window.devtoolsFormatters)

souenzzo17:10:23

works on my machine I'm on firefox developer edition It's prettyprintted

darwin17:10:22

ok, I downloaded beta version, let me try the developer one 🙂

souenzzo17:10:52

window.devtoolsFormatters on js console return "a thing"

darwin17:10:49

if they supported the same feature, that would be cool, we would just tweak https://github.com/binaryage/cljs-devtools/blob/master/src/lib/devtools/formatters.cljs#L14-L16

darwin17:10:09

and maybe remove that hacky detection of actual CF rendering

darwin17:10:19

no, it does not work for me (macOS 10.13, Firefox Developer Edition 57.0b7 (64-bit))

souenzzo17:10:03

window.devtoolsFormatters on console returns undefined?

bmaddy19:10:11

I'm trying to get cljs.spec.alpha/coll-of to work with eval-str. Thanks to a tip from mfikes, I think I need my :load function to look something like this:

:load (fn [_ cb] (cb {:lang :clj
                          :source the-complete-source-of-cljs.spec.alpha}))}
Does anyone know of a good way to get the source of cljs.spec.alpha? Alternatively, is it maybe possible to clone or just use the current compiler state?