Fork me on GitHub
#clojurescript
<
2017-11-06
>
fabrao01:11:55

@tkjone use like this

(def speech (new (.-webkitSpeechRecognition js/window)))
...
(defn apresentar-mensagem [mensagem]
  (log mensagem))

(defn- apresentar-resultados [resultados]
  (let [indice (.-resultIndex resultados)
        mensagem (.-transcript (aget (.-results resultados) indice 0))
        mensagem-ant (.-transcript (aget (.-results resultados) 0 0))]
    (if (not (and (= 1 indice) (= mensagem-ant mensagem)))
      (apresentar-mensagem (clojure.string/trim mensagem)))))

...
;; configure in your main
    (set! (.-continuous speech) true)
    (set! (.-lang speech) "pt-BR")
    (set! (.-onresult speech) #(apresentar-resultados %))
...

fabrao02:11:26

Hello all I use this

:npm-deps {"react-md" "1.2.4"}
                    :install-deps true
and I saw node_modules in root of project after starting REPL. Do I have to include it manually to use react-md? I didn麓t understand how to use it, any reference to give me?

Bravi14:11:32

hello. can someone enlighten me what does -> mean in this context please?

counter/->Controller

sundarj14:11:36

@bravilogy it's like the word to. e.g. toController

thheller14:11:11

its just a normal function, no special meaning

Empperi14:11:17

naming convention

Bravi14:11:29

oh, is it a part of the function name?

Bravi14:11:33

damn 馃槃

Bravi14:11:38

thank you haha

Bravi14:11:06

I was looking through docs and couldn鈥檛 find anything useful. now I see why

Bravi14:11:01

that鈥檚 amazing

Bravi14:11:05

so useful for functions where I鈥檓 converting something to something else

rauh15:11:09

@bravilogy Notable: When you define a record like so: (defrecord Controller [a b]) a function that constructs the record is created with the name ->Controller

Bravi15:11:35

thanks 馃憤

thheller15:11:10

there is also (map->Controller {:a 1 :b 2})

Bravi15:11:57

yes 馃檪

Bravi15:11:10

I鈥檓 looking into that framework at the moment

chang18:11:38

Does anybody have an answer to this SO question: https://stackoverflow.com/questions/28481272/clojurescript-error-could-not-find-or-load-main-class-clojure-main Tooling has been killing me with kindness 馃槵, so I decided to give the ClojureScript quickstart a shot. The question has been viewed 1.7k times so I guess a lot of people have been hitting the issue.

thheller19:11:15

@mohamedhayibor I do recommend using a tool to get started. try https://github.com/shadow-cljs/quickstart-browser or https://github.com/bhauman/lein-figwheel/wiki/Quick-Start. the official quick-start guide is rather low-level.

thheller19:11:59

I don鈥檛 think anybody seriously uses the cljsc command. I actually forgot it exists at all.

chang19:11:49

Thanks @thheller I got some luck "running figwheel on cursive" with re-frame's template but recently hit an issue where new dom elements were not being pushed to the browser. I thought that I had fundamental misunderstanding on tooling/setting, reasons of me circling back around to the basics. I'll dig around 馃槂

thheller19:11:04

ah ok, thought you were just getting started. the basics don鈥檛 cover live-reloading so you鈥檒l probably need to dig into #re-frame #reagent.

frerom19:11:36

I just noticed that empty string is truthy in clojurescript but falsy in clojure. Has it always been like this? I'm a little surprised

thheller19:11:42

it isn鈥檛 falsy in clojure?

frerom19:11:20

Sorry, I edited my message, it's the other way around

sundarj19:11:42

in javascript, empty strings are falsy

thheller19:11:55

not in CLJS

sundarj19:11:57

ah, never mind then

thheller19:11:33

[8:0]~shadow.user=> (if "" :truthy :falsy)
:truthy
[10:1]~cljs.user=> (if "" :truthy :falsy)
:truthy

frerom19:11:59

huh, interesting. Looks like I had a buggy version of planck

mfikes20:11:12

@frerom You had a version Planck where "" is falsey?

currentoor21:11:06

does anyone know of a good way to determine why the production build size for a cljs project is so large? like something that tells me how much JS is coming from which namespace?

anmonteiro21:11:14

@currentoor I鈥檝e used source-map-explorer successfully before

currentoor21:11:54

thanks @anmonteiro, did you have to do anything special to make it work with the advanced compilation output of a cljs project?

anmonteiro21:11:21

it won鈥檛 report the exact size of your bundle if you have foreign libs

anmonteiro21:11:29

simply because they鈥檙e usually not source mapped

currentoor21:11:28

so im guessing i have to have source maps on for this to work?

currentoor21:11:46

Error: An error occurred while trying to read the map file at /Users/karantoor/src/adstage-report-center/resources/public/js/intl-messageformat-with-locales.min.js.map
I鈥檓 getting a file missing error.

anmonteiro21:11:34

yes, you need to feed it source maps

currentoor21:11:12

got it, thanks

qqq22:11:27

the answer to this might be 'no, don't do that" when trying to write fast numeric code in CLJ, we have primtive-math when trying to write fast numeric code in CLJS -- is there anything to use ?

mfikes23:11:46

@qqq sometimes you get numeric optimizations for free from modern VMs (thinking of https://youtu.be/LopU-kMpe8I)