Fork me on GitHub
#clojurescript
<
2017-07-23
>
henrik04:07:30

Let’s say I’m running a Clojure backend, rather than a cljs/node one. How would I go about doing server side rendering with Reagent? Nashorn seems uncomfortable with the JS generated by cljs. Would I have to run a Node instance on the side and pass the task along to it?

henrik04:07:41

I had a look at that, tried to get Nashorn to parse base.js as an experiment, and it started complaining about the code style. That, along with stuff like this (str "reagent_server_rendering.core.main('" page-id "');") in the templates made me think that maybe it wasn’t the best/most mature option.

henrik04:07:11

The current idea is to use Node as a rendering layer between Clojure/API and CloureScript/Frontend.

henrik04:07:12

That’s three REPLs to juggle though.

robert-stuttaford05:07:36

@henrik https://github.com/tonsky/rum does server-side rendering without the need for server-side JS

robert-stuttaford05:07:56

i use it isomorphically. works 👌

henrik06:07:36

@robert-stuttaford Indeed, which is awesome. I’m not looking at Reagent specifically necessarily, just a generic way of pre-processing arbitrary JS.

robert-stuttaford06:07:53

Clojure backend, advanced-compiled cljs frontend, sharing .cljc source with the Rum defcs in it

robert-stuttaford06:07:25

right. if you need to run other JS, then yes, you’d need a JS VM 🙂

henrik06:07:49

Yeah, indeed! It’s annoying to know that there is one embedded in JVM, but that it’s kind of slow and finicky.

Oleh K.10:07:23

I've moved these libraries into package.json and now got an error on react-native-packager start with optimizations :none : No such module 'path'. But with optimizations :simple all works.

Oleh K.10:07:48

and, of course, this doesn't work with figwheel because figwheel requires only optimizations :none

pesterhazy10:07:00

@okilimnik what are you trying to accomplish?

pesterhazy10:07:14

If you're using re-natal, did you run re-natal use-component moment?

Oleh K.11:07:12

@pesterhazy I'm just trying to perfom @dnolen's request to give a try for clojurescript master and to move all node dependencies into project.clj. And in this case there is no need to add modules into .re-natal

henrik11:07:31

What’s a good library for client-side routing?

lxsameer11:07:48

There are several

lxsameer11:07:17

I'm using secretary which is just fine

lxsameer11:07:25

you can use bidi as well

henrik11:07:48

Thanks! Any opinions as to why one would be preferable to the other?

lxsameer11:07:59

Also I really want to port Pedestal's routing lib to cljs as well. It's the best thing i used for routing

lxsameer11:07:36

secretary is straight forward bidi is good too but setup process is painful 😞

henrik11:07:45

I’ve played with it briefly, and it’s great. I think there’s a general push towards .cljc for Pedestal.

lxsameer11:07:05

yeah I hope so. it's great

lxsameer11:07:25

I'm creating a fullstack framework for clj

lxsameer11:07:52

base on pedestal , my goal is to replace secretary with pedestal routing on client side as well

lxsameer11:07:22

which one is a better practice (i have 2 async channel for websocket in/out) ? 1) Returning async channels from a functions and pass them around 2) use global vars for async channels and require them on demand ?

darwin11:07:28

@lxsameer what is a better practice? 1) returning values from functions 2) using global vars/atoms and referencing them on demand?

darwin11:07:59

short answer: it depends

lxsameer11:07:40

depends of what ?

magra12:07:08

I do have another event-handler hooked to the "plz" and "ort" input elements. They work.

thheller12:07:34

@magra you might be running into a weird issue where closure optimizes the call away incorrectly

thheller12:07:25

looking for the “fix” I have written down somewhere

thheller12:07:20

@magra I think it was :compiler-options {:check-types :warning}

magra12:07:03

@thheller thanks again! That works like a charm!

oluwaseun14:07:22

Hi guys, does anyone know how to get RE-FRAME or RE-COME to work properly in a NEW POPUP window created with window.open() ? I want to create a popup window that I can render re-com elements into - but when I try to do this several things are not working properly - I am assuming because the necessary javascript / other stuff is not included in the new window ?

oluwaseun14:07:34

edit Hi guys and gals

oluwaseun14:07:49

*edit RE-COM sorry

sbrg16:07:57

Hello. I've been playing around with datomic recently, and I'm interested in using datomic for an application with a frontend written in clojurescript. As far as I can tell, datomic.client doesn't support CLJS. I was kind of hoping for a solution that would basically let me deal with clojure data all the way through, without having to write, say, a rest frontend for my queries. What is the best way of going about this(AFAIK, the rest interface for datomic has been deprecated, so I'd rather not use that)

hmaurer16:07:43

@sbrg Disclaimer: I am new to ClojureScript and haven’t been looking into it much, but I am also experimenting with Datomic as so stumbled upon a few solutions

hmaurer16:07:51

http://precursorapp.com is built on DataScript + Datomic

sbrg16:07:13

I had seen datascript, but as far as I could understand it was for directly interfacing with datomic. But I'll take a look at the links, thanks!

hmaurer16:07:39

@sbrg as far as I know any interfacing between a frontend and datomic is very much experimental at this point

sbrg16:07:08

I see. It just seems so .. perfect to be able to speak to datomic directly from the frontend. But it looks like precursor has a pretty nice setup going with datomic + datascript + sente for real-time updates

hmaurer16:07:46

@sbrg there are a lot of security implications that you have to consider. But Datomic’s filters and transaction log makes it much easier to do this (as shown by precursor)

bspaulding17:07:00

i’m seeing a behavior difference with int in clj/cljs:

(int \a) ; 97 in java land
(int \a) ; 0 in js land

bspaulding17:07:42

is this a known issue or something?

bspaulding17:07:54

or intentional perhaps heh

bspaulding17:07:13

Yea, saw that. Ok. I guess I'm stuck with reader conditionals to stay cross platform. Thanks!

hmaurer17:07:12

@bspaulding I’m not familiar with Clojurescript though, there might be a better answer than this!

hmaurer17:07:59

@bspaulding nevermind, I can give you a better answer

hmaurer17:07:16

As mentioned in https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure, Javascript does not have a character type

hmaurer17:07:22

so character literals map to single-character strings

hmaurer17:07:31

now, if you check the source code for the int function:

thheller17:07:38

@bspaulding (.charCodeAt \a 0)

hmaurer17:07:54

it is implemented as a bitwise or

hmaurer17:07:52

So basically, if I am not mistaken, (int \a) in ClojureScript is the same as "a" | 0 in js

hmaurer17:07:55

which evaluates to 0

hmaurer17:07:20

So yeah, .charCodeAt is the way to go

urbank22:07:25

Hm, with core.match I'm getting var undeclared warning when using variables in the match.

urbank22:07:31

But not in all circumstances.

urbank22:07:09

Shuffled some stuff around and know it works. 😕

lingeeal22:07:46

hi, this line in handler.clj [:link {:rel "manifest" :href "manifest.json"}] works in reagent's template dev mode (where manifest.json is in resources folder), but does not work in production mode.