Fork me on GitHub
#clojurescript
<
2018-02-03
>
orestis10:02:23

Are there any frameworks/templates for integrated client-side and server-side (Node.js) clojurescript projects? I’m fine if I need the JVM to compile, but the final server should be node only.

pfeodrippe12:02:54

Hi, people, I'm trying something with chromex (https://github.com/binaryage/chromex) and never have tried clojurescript before for any application. How could I open (or connect) a repl to eMacs só my workflow could be improved?

pfeodrippe13:02:27

Or at least there is some more improved workflow to work with this?

Petrus Theron14:02:23

Hey guys. Having a bit of hell with React Native on a deadline. Ditched metro bundler after too much pain. Trying Haul, but getting this error when the bundler serves up index.ios.js: Unhandler JS Exception: goog.require could not find: cljs.core. Suspect some module resolution thing. Have added :target :nodejs to my cljs build task (I use boot), but to no avail. Does anybody have any idea why react native is unable to load my cljs namespaces?

joelsanchez16:02:09

how do people split their code on development? cljs modules don't work with no optimizations, and figwheel does not work with optimizations

jtth17:02:44

Newbie question: is there a kind of minimal front-end template or framework or concept around deploying clojurescript in a way that isn't an SPA with a lightweight backend? Clojurescript would be used here and there for this and that feature (draggable cards, &c, whatever) but the page wouldn't be structured as an SPA. Is that a thing? If it is, can someone point me in a direction?

thheller17:02:43

@joelsanchez shadow-cljs supports :modules in development

jikuja17:02:31

btw is there boot task for shadow-cljs yet?

thheller19:02:25

@jikuja I don't use boot personally so I haven't worked on anything. there was some work done a few weeks ago https://github.com/jgdavey/boot-shadow-cljs

gklijs19:02:52

@jtth did not really found anything like that, so build something myself. The basic idea was to have as much as possible of the rendering if the pages in cljc code. And to be able to build a page based in the path, witch can also be cashed. This way you can get almost all the HTML direct from the server. For the JavaScript I build some utility functions on closure.

jrbrodie7720:02:14

I’m looking for some advice on js interop in a reframe app. I’m using the AWS SDK to fetch credentials. The js method to get creds requires a callback which is handed the credentials on success. The only reasonable thing I can think to do is to pass around an async core channel... so the callback that receives the credentials puts the credentials into the channel. But that means that all of my code that uses the credentials ends up taking the channel and using go blocks everywhere. Seems a bit tedious. Any patterns for dealing with these all these js callbacks?

noisesmith20:02:36

in some cases you can start with a placeholder in an atom, and reset the atom contents in a callback

jrbrodie7720:02:27

Would I then attach watchers to the atom? Chaining the calls seems like the hard part. I need a way to wait.

noisesmith20:02:28

for things that always need to happen at startup, I found it convenient to use stuartsierra/component and channels to coordinate the initializations of various things getting things from APIs into the browser

noisesmith20:02:32

well a watcher on the atom doesn't give you much that the callback would have done in the first place (except you can set up N watchers I guess)

noisesmith20:02:01

but you can for example setTimeout if the atom isn't ready

noisesmith20:02:38

but that's yet another callback, which is why core.async starts to get interesting - instead of nested callback lambdas you have channel using sequential statements (on a syntax level at least)

jrbrodie7720:02:30

I think the async route might work. I can also use the db map in reframe to coordinate things, but it gets really ugly. (I could have en entry called :next-thing-to-get-called and then the creds callback could fire that event... seems like a bad idea though)

noisesmith20:02:27

the tricky thing, as you notice, is that core.async becomes contagious - eventually it seems like all your code is running inside go blocks

jrbrodie7720:02:59

Yes! I wish cljs had the blocking version of get. Thanks for your tips.

noisesmith20:02:27

@jrbrodie77 another thing, pragmatically, is that code that shouldn't be in a go block can still use take! with a callback - you can choose your poison in a given context, whether it makes more sense to use a go block or a callback

justinlee21:02:27

@jrbrodie77 if it helps: I use the atom-placeholder technique and it seems to be the simplest. You just put nil in the credentials slot initially. Then in a top-level component, deref that and render a “logging in” placeholder if it is nil or render your page if non-nil. Then you can just use the credentials in your code because you know that you won’t be in that codepath unless you’ve got them already.

justinlee21:02:11

on a different topic: are atom watchers executed synchronously when an atom is updated in cljs? or do the updates happen during the next tick?

justinlee22:02:02

to answer my own question, synchronously