Fork me on GitHub
#clojurescript
<
2019-05-20
>
todo03:05:35

Anyone have a nice workflow for Rust + cljs? I have some high performant webgl/wasm32 primitives written in Rust. Now however, I want a way to interact with all these objects from cljs, so I need some way to handle Rust <-> cljs serialization.

gklijs05:05:57

I tried running wasm from clojurescript about half a year ago with little success. You can get some typescript generated with the wasm but I don't think that would help in this case. What works the flow of information be, and how does the data look like? There is the serde library in Rust that can be used for 'dynamic' data like Json.

todo03:05:46

(perferably auto generated)

karkunow13:05:31

Hello everyone! I wonder if anyone here uses some lenses/prisms libraries in your projects?

robcorp19:05:30

I've been rather pleased with Specter https://github.com/nathanmarz/specter

robcorp19:05:11

I'm no expert with it, though.

karkunow08:05:37

@U87UFHEUV Yes, saw it. But I don't like it, because of the approach and tool's naming. The author is using his own terminology there and not thinking globally in terms of the optics, optics laws and mathematics. Which, I think, implies that using Specter could be pretty bad for a project.

karkunow08:05:54

Anyway, thanks for mentioning it!

👍 4
kszabo13:05:31

hey, yes, we use https://github.com/ctford/traversy, pretty happy with it

❤️ 4
karkunow16:05:37

@thenonameguy thanks! will take a closer look at it!

Alan Thompson16:05:57

The Tupelo.Forest lib allows you to process tree-like data structures in powerful ways: https://github.com/cloojure/tupelo/blob/master/docs/forest.adoc

alza17:05:56

Hi folks, quick ClojureScript question..

#?(:cljs 
   (defn fs-working
     []
     (.openSync js/fs "file.txt" "r")))
The above code works at a Node JS Piggieback repl, but when called from a test (using cljs-test-runner) I get
#object[ReferenceError ReferenceError: fs is not defined]
Any ideas? simple_smile

nenadalm19:05:07

js/fs? I've never seen that. Shouldn't you require that with cljs.node/require like here: https://github.com/macchiato-framework/macchiato-core/blob/8c0ae5c47b3495a171a028e65bd989bdce2c4915/src/macchiato/middleware/file.cljs#L9? Also I suppose you run the tests in node environment - not with some browser.

alza11:05:19

Hi, yes I agree, I've never seen js/fs before, but interestingly it does work in my Piggieback repl (but not from tests, or when compiled)

alza11:05:54

I was using this js/fs form instead of js/require to try and workaround an issue I was having trying to use the macrovich library: https://github.com/cgrand/macrovich/issues/8

alza11:05:21

However, since js/fs didn't work in tests or compiled (and I didn't want to spend additional time figuring out why), I went for a js/require based approach in the end (once I'd figured out how to make it work in a macro, and with macrovich)!

Dante T. M.18:05:18

Setting up emacs on a new Arch Linux laptop and getting an nrepl timed out error. Lists op classpath as the detail. I'm using ClojureScript mode and then cider-jack-in-cljs with figwheel as the next option. This project loads correctly when using figwheel without emacs on the same machine. I updated the nrepl-sync-request-timeout to be nil, so I'm really not sure what's going on.

Dante T. M.18:05:45

Any help would be appreciated.

dpsutton19:05:32

Grab the start up command it’s using from the messages buffer and run it from the terminal

dpsutton19:05:35

Oftentimes there’s a mismatch between the lein version and nrepl version

Dante T. M.19:05:31

Good call. To the terminal

Dante T. M.20:05:31

Doh! So, reading the messages buffer I noticed a message saying that my cider-nrepl was newer than the byte-compiled version...sigh

Dante T. M.20:05:28

Recompile the cider directory and bingo, nrepl no longer times out. I'd updated the timeout function, but it wasn't being used

Dante T. M.20:05:19

@dpsutton not the exact approach you recommended, but thanks for prompting me toward the location to help myself

dehli20:05:34

Is it possible to have (clj->js (random-uuid)) return a string instead of a js object?

thheller20:05:32

you mean like

[5:1]~cljs.user=> (str (random-uuid)) 
"a0a54647-4605-4fcd-b7bd-3371e72fbc5b"

thheller20:05:00

as per clj->js you can achieve that via the protocol used in clj->js

thheller20:05:00

(extend-protocol IEncodeJS cljs.core/UUID (-clj->js [x] (str x)) (-key->js [x] (str x)))

dehli20:05:16

oh no way! that's awesome 🙂 thanks!