Fork me on GitHub
#clojurescript
<
2018-12-21
>
ahungry03:12:53

How do you guys test promises in clojurescript? I'm trying clojure.test, but putting my assertion in my then block does not seem to work (the run-tests command finishes before the then is evaluated)

ahungry03:12:11

I'm sure i'm missing some alternative to deftest like deftest-async of something

ahungry03:12:41

ah I got it

ahungry03:12:15

I can define (deftest) the test itself in the callback via some wrapper like generate-promise-tests, then execute assertions from that snapshot of promise return values via (run-tests)

richiardiandrea04:12:10

I have a lib, at one point it will be made open source but yeah the classic pattern is async then your is inside the .then

mattly05:12:44

are there any view libraries in clojurescript for the DOM that don't rely on React in some form or another?

rutledgepaulv13:12:50

I haven't tried it but this was posted on the mailing list recently https://bitbucket.org/sonwh98/mr-clean/src/master/

aisamu14:12:20

This one is very nice and has reconciliation (I've used the lib but not this feature): https://github.com/jeluard/hipo

lilactown14:12:02

I’ve heard good things about hoplon

☝️ 4
mattly05:12:08

that still maintain a (f state) => view style workflow?

aisamu14:12:20

This one is very nice and has reconciliation (I've used the lib but not this feature): https://github.com/jeluard/hipo

lilactown15:12:43

I’m trying to discover a way to detect the equivalent of CLJ class in CLJS, if only in some cases.

aisamu15:12:14

I might be missing something, but have you checked type?

aisamu15:12:33

(type [])
;=> cljs.core/PersistentVector

lilactown16:12:07

that returns the constructor as a value

lilactown16:12:18

I want either a string or a symbol. something serializable

lilactown16:12:01

(str (type []))
;; => "function (meta,cnt,shift,root,tail,__hash){\nthis.meta = meta;\nthis.cnt = cnt;\nthis.shift = shift;\nthis.root = root;\nthis.tail = tail;\nthis.__hash = __hash;\nthis.cljs$lang$protocol_mask$partition0$ = 167666463;\nthis.cljs$lang$protocol_mask$partition1$ = 139268;\n}"

aisamu16:12:21

Oh, I see! I might still be missing something, but would this work then?

(print-str (type []))
;; => "cljs.core/PersistentVector"

lilactown15:12:04

I notice that there’s a cljs$lang$ctorStr: "cljs.core/PersistentVector" on many CLJS data structures

lilactown15:12:28

is there a stable way to access that? does it persist through advanced compilation?

dnolen16:12:25

that's there for REPLs, it hasn't changed in years but unlikely to make any promises about it

lilactown19:12:57

@dnolen I am finding that I’d like to be able to get this type of information when serializing datafied stuff and putting it over a wire

lilactown19:12:14

I’m thinking it would be quite useful for REBL-like things

dnolen20:12:41

@lilactown first question is how would you accomplish this in Clojure?

dnolen20:12:09

are you doing this by going through the var there?

lilactown20:12:48

in CLJ, they’re doing (-> x class .getName symbol)

dnolen20:12:24

we could implement getName on ClojureScript types

4
dnolen20:12:30

so there's a proper API

dnolen20:12:26

(-> x type .getName symbol) or something like that

lilactown20:12:27

(-> x .-constructor .-name) is so close >_< but it has too many gotchas

dnolen20:12:20

@lilactown I dunno, for REBL use does this really matter

dnolen20:12:40

this kind of reflection is great for dev

dnolen20:12:47

I don't know if it matters much for applications

lilactown20:12:36

@dnolen what I’m working with is a situation where you have custom views for a particular data type (e.g. JS error, a DOM node, or a database query) and you’re viewing it remotely. what I’m finding is you pretty much have to separate the app into two parts: the part that calls datafy and nav, which lives in-process with a ClojureScript app, and the remote UI

dnolen20:12:14

I think this is necessary no matter how you look at it

dnolen20:12:18

ClojureScript runs somewhere else

lilactown20:12:40

when you want to e.g. view a JS error, it can get datafied into a map and sent over the wire. but then how do you know it was originally a js/Error or a DOM node so your custom viewer can kick in?

lilactown20:12:40

that’s the problem I’m trying to solve

dnolen20:12:44

right what I'm saying is constructor.name is fine

dnolen20:12:47

it doesn't need to work everywhere

dnolen20:12:53

only prod stuff needs to be water tight

lilactown20:12:46

ah fair point. so we don’t worry too much about optimizations / cross platform

dnolen20:12:24

yeah exactly

dnolen20:12:30

this is just while you're developing

dnolen20:12:38

90% you're in Chrome running cljs-devtools etc.

dnolen20:12:25

while it would be cool if it worked everywhere - there's some huge diminishing returns if you try to pursue that

ITtrekkie20:12:10

Ok guys, I love Clojure. Clojure is awesome, I am running it on my PCs, I have it running on Android (clojurescript), Now I want it on iOS, I am using re-natal and I have an app ready to go, even code signed and everything 🙂 But.... it seems like once it runs on my iOS device, it sits there waiting for figwheel to feed it JavaScript 😕 any advice?

lilactown20:12:49

@cole.yarbor I’m not super familiar with re-natal, but you might try the #re-natal channel if you don’t get a response here

ITtrekkie20:12:00

@lilactown thanks, I appreciate it! 🙂

mfikes20:12:43

@cole you will actually want #cljsrn But there are two answers to your question: If you want to dev that way, you need to tell re-natal you want to use your device. If you want to just run the app, you do a prod build.