Fork me on GitHub
#clojurescript
<
2018-09-21
>
Diego00:09:42

Has anybody used accountant with secretary (in a regent app)? I want to implement navigation and page “scrolls” for links like /some-page#my-anchor. How can I solve this? The accountant docs are not clear about this point.

Braden Shepherdson03:09:24

I'm using boot and can't get the repl to work at all. I tried Tenzing as well as following the modern-cljs tutorial. in both cases, boot repl --client just hangs.

nha09:09:42

what about boot repl ? Also there is a #boot channel

fergalbyrne10:09:45

can anyone point me to the cljs-dev channel?

fergalbyrne10:09:48

Doh, didn't know how to use Slack.

biscuitpants11:09:19

has anyone found strange problems with using partial on event handlers?

biscuitpants11:09:41

so e.g on the mousedown event we have a handler that is a partial, where the last arg would be the e

biscuitpants11:09:07

the function being partialed is forward declared, too

biscuitpants11:09:57

we kept getting the error object [Mouse Event] is not ISeqable. changing from partial to (fn [e] ...) fixes it

orestis11:09:10

Can you paste a snippet on how you construct the partial and how do you attach it to the mousedown event?

biscuitpants11:09:07

(let [callback (partial on-mouse-down *state opts)]
  (.addEventListen element "mousedown" callback true))

biscuitpants11:09:00

where on-mouse-down is a declare’d fn. the function right now has a simple prn. the prn isn’t even hit

cursork11:09:21

partial is taking the value of #’on-mouse-down at the time it is created

cursork11:09:38

See the difference between (partial on-mouse-down ...) and (partial #'on-mouse-down ...)

biscuitpants12:09:54

interesting. the strange thing is that this always seemed to work. maybe the order in which the code was loaded was just lucky before?

cursork12:09:58

Maybe? I can definitely repro it with (defn x [] 'a) (def y (partial x)) (defn x [] 'b) (y)

danieroux13:09:18

I ran into my first :optimizations :advanced issue. I get this:

Uncaught TypeError: Cannot read property 'type' of undefined
    at Object.onEachFeature (titan.js:935)
And this is the offending code snippet:
:onEachFeature (fn [data layer] (let [properties-js (.-properties data)
                                     type-js (.-type (.-geometry data))]
                                 (if (= "Point" type-js)
                                   (r2d2-popup layer properties-js))))
How do I begin to debug this? I assume something needs to be externed that isn't?

thheller13:09:49

@danie probably the .-geometry is getting renamed. try adding (fn [^js data layer] ...)

danieroux13:09:32

@thheller that's now a different error:

titan.js:935 Uncaught TypeError: b.Bf is not a function
    at Object.onEachFeature (titan.js:935)

thheller13:09:59

likely some (.fooBar thing) call getting renamed

thheller13:09:54

compiling with :pseudo-names true also helps to identify the problem

danieroux13:09:11

@thheller Woot, thank you. I marked the r2d2-popup function with ^js as well, that solved it all.

richiardiandrea15:09:04

Is anybody using jest snapshot testing with ClojureScript by any chance?

👍 4
rsslldnphy20:09:05

i’m trying to get it working at the moment

rsslldnphy20:09:03

had some success in getting enzyme to render the view in a comparable way… just trying to work out how to get cljs to write the snapshots to a file for later comparison

richiardiandrea22:09:27

Yep I think that was my challenge as well. Most because I would like to get a snapshot file out of a rest call

rsslldnphy22:09:32

did you have any luck? currently trying to get a node repl working for running tests

richiardiandrea23:09:48

no but I have to say I didn't try that hard, move to other things for now, but I could help if you have something already

rsslldnphy17:09:50

thanks! i have a few ideas i’m going to try out tonight, will share what i come up with

rsslldnphy21:09:23

it has some limitations, which hopefully i’ll work out fixes for, but i’ve basically got it working!

rsslldnphy21:09:25

need to find a good string diffing function to display failures better, and at the moment it relies on you reevaluating your test file before running it due to the use of a macro, but it’s a start

athomasoriginal03:09:20

@U06964A7P @U0C8489U6 Im not sure how much you got working on your own but here is a demo repo I setup for working with Jest and ClojureScript https://github.com/tkjone/demo-clojurescript-jest I have not tested snapshots yet, but they should be relatively easy once Jest is actually setup to work. Hope this helps!

rsslldnphy07:09:03

Thanks, I’ll take a look!

jmckitrick16:09:58

I recently saw a question on ClojureVerse about CLJS frameworks. It was suggested that Reagent and Reframe are fine for ‘toy’ to medium sized apps, but that Fulcro was better for large, complex apps. Any thoughts on that? I’d almost forgotten about Untangled, and missed when it was renamed to Fulcro.

dnolen16:09:48

I think all the options are capable

dnolen16:09:05

but Fulcro has more built-in stuff and that could be a great fit

jmckitrick16:09:20

I’ll check it out.

jaawerth17:09:04

@jmckitrick I can't speak to Fulcro but in general I find descriptions of minimalist frameworks as being for small/toy applications to be reductive. What i find the big opinionated frameworks bring to the table is a set way to organize things, which can benefit large apps/orgs by reducing the need for imposing your own organizational structure at the cost of flexibility

jaawerth17:09:26

But minimalist frameworks can be plugged into a larger flow quite well, it just may require more initial design work

souenzzo21:09:47

hey I'm having problems with transit On JVM:

(let [out (new ByteArrayOutputStream)
      writer (transit/writer out :json)]
  ;; [com.cognitect/transit-clj "0.8.313"]
  (transit/write writer {:foo 39225.8500M})
  (.toString out))
=> "[\"^ \",\"~:foo\",\"~f39225.8500\"]"
On Browser (FF)
(let [data  "[\"^ \",\"~:foo\",\"~f39225.8500\"]"]
  ;; [com.cognitect/transit-cljs "0.8.256"]
  (t/read (t/reader :json) data))
=> {:foo #object[Transit$TaggedValue [TaggedValue: f 39225.8500]]}

dnolen21:09:29

that’s expected

souenzzo21:09:22

How should I handle it? can I get "39225.8500" from it?

mfikes21:09:30

Dunno if it is public API, but .-rep accesses that field

souenzzo22:09:13

There is some docs about it? transit still a recommended way to get exchange data between clj <> cljs(browser)?

thheller22:09:33

you are supposed to supply a custom handler that returns the value you want. since JS doesn't have a default BigDecimal impl

souenzzo22:09:17

my application stopped working overnight only for a growing number 😞

souenzzo22:09:35

(extend-protocol IRenderData
  types/TaggedValue
  (render-data [v]
    (cond
      (types/isBigDecimal v) (.-rep v)
      :else (str v)))
  js/Date
  (render-data [v] (a/inst->date-str v))
  number
  (render-data [v] (str v)))
Is it a possible/stable solution?

dnolen22:09:55

rep will be a string

dnolen22:09:06

find a BigDecimal thing for JavaScript if you need this - they exist

souenzzo22:09:28

I just need to show for now

dnolen22:09:39

then sure - string will be fine

dnolen22:09:51

and yes that code is stable

lilactown22:09:29

I'm trying to use clojure.test.check.clojure-test's defspec macro, and it's not being picked up by my test runner

richiardiandrea22:09:15

@lilactown yeah shadow-cljs does not work with it. I use olical/cljs-test-runner at the moment

Garrett Hopper22:09:47

How does :closure-defines work in a repl? I know if goog-define is used after the repl is started it doesn't work, but should it work if the repl is requiring a namespace that already has it?

mfikes23:09:11

@ghopper :closure-defines works in a REPL when you use goog-define after starting the REPL:

$ clj -m cljs.main -co '{:closure-defines {cljs.user/foo "abc"}}' -r
ClojureScript 1.10.339
cljs.user=> (goog-define foo "xyz")
#'cljs.user/foo
cljs.user=> foo
"abc"

Garrett Hopper23:09:58

@mfikes I'm an idiot... I had the key of the map as a string. Thanks

👍 4
mfikes23:09:49

A string should work as well

Garrett Hopper23:09:51

Oh, it can be a string, but it has to have the namespace.

Garrett Hopper23:09:58

Great timing 😉

mfikes23:09:30

Yeah, and probably munged if needed. (TL;DR, I bet the string is essentially JavaScript at that point.)