Fork me on GitHub
#clojurescript
<
2015-06-05
>
spicydonuts00:06:52

Has anyone looked at Deku at all? It's ridiculously small compared to React and I kinda like the look of the API, but I haven't tried it yet. (https://github.com/dekujs/deku)

mikethompson00:06:50

@micha hey, thanks. Hoplon and Elm were significant influences on re-frame.

micha00:06:36

@mikethompson: thanks! i'm 100% on board with re-frame (maybe minus react 😄 )

micha00:06:02

i think the water cycle is a better illustration of the concept than the thing i did http://hoplon.io/img/arch-full.png

mikethompson00:06:15

@micha I love a good colour gradient, so I'm a fan. simple_smile

mikethompson04:06:25

@ul I really appreciate you doing the archiving, thanks! http://clojurians-log.mantike.pro/

mikethompson04:06:13

(although it doesn't look like the google bot has deeply visited yet)

ul04:06:16

thanks! i tried to force him to visit from search console, but no luck

mikethompson04:06:38

Send a private email from your gmail account, including the required link. I've found that triggers a bot visit soon afterwards. simple_smile

nidu05:06:59

Hello, did anybody have experience of writing WebGL apps in ClojureScript? What option did you find good for you - using cljs-webgl or wrapping some library like threejs or just plain js interop?

denisj05:06:53

@nidu: No specific WebGL experience or opinion here, but keep in mind some of them are already available on https://github.com/cljsjs/packages e.g. three and hence on clojars.

blissdev05:06:12

nidu: have you seen this?

nidu05:06:55

@denisj: thanks. three is a very thin wrapper for threejs. I initially thought it's a wrapper for d3 because it's mentioned as a home website at https://clojars.org/cljsjs/three

nidu05:06:01

@blissdev: that's more about cool live editing than about graphics though i found some interesting stuff in :require)

dnolen13:06:50

@nidu: it’s actually about live editing WebGL tutorials. The tutorials use a new library called Gamma by Kovas Boguta. It’s worth looking into and I think a better direction than the alternatives.

ej13:06:58

what’s the consensus on using something like rente/sente?

ej13:06:15

*anyone had experience with it?

angusiguess13:06:38

I've got sente running in a project currently in conjunction with some om components and it works reasonably well, but the project isn't very complex yet.

ej13:06:02

what’s the logic behind sente auth?

teslanick14:06:19

How do you mean?

ej14:06:57

create a compojure POST route for /login, use friend/buddy for the auth, then use the auth middleware with ring? so auth before initialising the sente websockets?

ej14:06:24

am i correct in that thinking? I’m not all to common with clojure api backends yet

teslanick14:06:24

If you authenticate after you init the socket (or if you change your authentication at some point) you need to restart the socket.

teslanick14:06:30

Don't totally remember how to do that.

ej14:06:06

oh fair enough, bit confused but i’ll research more simple_smile

ej14:06:32

oh makes sense! i get it now!

hlship14:06:43

BTW, in terms of making my reagent app a bit more "reload friendly", my solution was to add a small bit of indirection.

(defonce ^:private pages
         (atom {:loading (fn [] [nav-border {:title      "Loading ...."
                                             :hide-login true}])}))

(defn register-page
  "Maps a keyword to a component function, used by [[current-page-view]]."
  [name f]
  (swap! pages assoc name f))

(defn current-page-view
  "Determines which 'page' to view based on the :current-page key of the app-db, and previously registered
  pages (via [[register-page]])."
  []
  (let [current-page (subscribe [:current-page])]
    (fn []
      [(get @pages @current-page)])))

ej14:06:05

so the non-logged in user has no uid, they get assigned a uid serverside after auth, clientside restarts the socket connection, new socket has the new session uid!

ej14:06:54

do an if-let @hlship ?

hlship14:06:01

So the data in the app-db is just a keyword (which is an improvement), and reloads of the namespaces will update the pages atom with new functions. Now everything works without any need to mess with secretary and/or History.

ej14:06:02

should stop the app crashing i believe

hlship14:06:51

@ej don't think an if-let helps me here, the :current-page key should always match an entry in the pages map; if not, I'd be more likely to add a default to the get call, to a "not yet implemented" view.

ej14:06:27

(defn init-routes []
  (secretary/set-config! :prefix "#")
  (defroute "/home" []
    (dispatch [:render-component :home]))
  (defroute "/next-page" []
    (dispatch [:render-component :next-page]))
  (hook-browser-navigation!))

(register-sub
 :component-to-render
 (fn [db _]
   (reaction
    (condp = (:component @db)
      :home home/component
      :next-page next-page/component
      (error-page)))))

ej14:06:35

i believe i had something like that

ej14:06:49

and yeah true my bad.

nidu14:06:36

@dnolen: as far as i can see Gamma covers shaders only using goog.webgl for everything else. I was looking for a more general solution like threejs or scenejs (declarative style of this one would probably play very well with clojurescript immutability).

hlship14:06:45

@ej I really wanted to avoid that condp

xeqi15:06:33

nidu: I played around with https://github.com/Izzimach/om-react-pixi and it was decent. He's also built https://github.com/Izzimach/react-three, though I don't see any specific cljs wrappers for it

leonoel15:06:12

works fine in clojure

leonoel15:06:06

and works fine in cljs if I use ifs instead of or / and

dnolen15:06:54

@leonoel: need more information than “error”. What error?

leonoel15:06:35

clojure.lang.ExceptionInfo: recur argument count mismatch

leonoel15:06:45

on last line

dnolen15:06:47

@nidu there’s also the driver component. As far as scene graph maybe toxi has something?

akiva15:06:20

[whistles innocently]

dnolen15:06:28

@leonoel: I’m actually surprised that works at all. I would just rewrite your conditional. While there may be a bug that’s going to be pretty low priority.

leonoel15:06:26

@dnolen ok more likely due to cljs or core.async ?

leonoel15:06:25

ok thanks I will stick with the if version

nidu16:06:48

Thanks for great links! @xeqi: react-three looks very promising. @dnolen: Codefactory looks decent. It seems like rendering is based on http://thi.ng (or maybe http://thi.ng came from codefactory) mostly or entirely.

mystery16:06:47

Do people have recommendations for books?

jonas16:06:53

@mystery: clojurescript books? I’m not sure there are any that’s up-to-date

dnolen16:06:09

Luke Vanderhart and Stuart Sierra are working on a new edition of ClojureScript: Up & Running

jonas16:06:30

@dnolen: that’s great news!

dnolen16:06:44

still that’s not going to help with fast rate of change wrt. the various React bindings

dnolen16:06:54

I strongly suspect once people get Relay there’s going to be lot of overhauling.

mystery16:06:57

Oh rad. I really like the textbook approach to stuff...

jonas16:06:36

I wonder if they’ll release Relay at react-europe conf

jonas16:06:16

so much talk about it and so little code..

dnolen16:06:43

heh yeah, but that’s why I keep saying there’s no need to wait.

dnolen16:06:51

It’s a design principle more than anything else.

jonas16:06:14

dnolen: agreed.. the various blog posts has been interesting. As well as your work on om.next

tcrayford16:06:46

@dnolen: I did some more digging in the slides about relay and mutation - looks totally like they have support for stuff like tx-report-que

dnolen16:06:08

@tcrayford: yeah they alluded to it at the end.

tcrayford16:06:25

@dnolen: think om.next might the final brick in the wall that moves yeller away from server rendered templates

rtorr16:06:59

Speaking of relay, (maybe I read some stuff wrong) I am kind of curious how Datomic will also fit into that (still need to try it out).

rtorr16:06:19

So ready for Relay stuff to start being released.

zane16:06:02

I'm not sure I'm phrasing this well, but here goes: So, in Om, for component data that you don't expect to change is it acceptable to simply set it via a closure, or does it belong in the component-local state? e.g. (defn my-component [unchanging-data data owner] …) followed by use of my-component with partial.

jonas17:06:12

zane: with closure, do you mean wrapping an om component in a closure.. something like:

(defn some-component [x]
  (fn [data owner]
    (om/component
      (span nil x))))

jonas17:06:59

that’s not a good idea since it will remount the component on each render

jonas17:06:35

@markstang: my comment above was about my code snippet, not yours

markstang17:06:22

😃 Just an example...

zane17:06:59

@jonas: The function that creates some-component takes an additional prefix argument, which is later parameterized via partial.

dnolen17:06:39

rtorr: Datomic is basically a perfect fit for a Relay style system.

rtorr17:06:15

@dnolen: Yeah, I am hoping to get time to play with it soon. Waiting for more infos.

rtorr17:06:41

Thanks for reaffirming

dnolen17:06:07

@rtorr: Datomic supports Pull syntax and can return deltas, there’s not much more info to know simple_smile

zane17:06:18

@dnolen: Yeah, that's mainly about the pull syntax, right?

dnolen17:06:19

Om Next queries are expressed as Pull syntax fragments

jonas17:06:01

(def some-component
  (fn [x data owner]
    (om/component
      (span nil x))))

(om/build (partial some-component "foo") ..)
I’m pretty sure this will also remount for each render

zane17:06:29

@jonas: Okay, good to know. So the right thing to do is put it in component-local state?

jonas17:06:12

zane: Don’t take my word for it.. you’ll need to check to make sure.

akiva17:06:44

Hey, @dnolen, is there a document or talk somewhere that documents the expected changes in Om Next?

jonas17:06:46

@zane: One option is to put the prefix (x in my example) in the data

rtorr17:06:08

@dnolen: I am more speaking to checking it out myself so I am not so ignorant with it, and integrating it with react. I am also looking forward to using the relay model with react itself and seeing how gql plays out.

zane17:06:16

@jonas: Hmm. It's really not conceptually part of the application state.

dnolen17:06:01

@akiva: not beyond the source

akiva17:06:13

Cool, thanks.

gary17:06:51

@tcrayford I had that same thought, (moving from server side rendering to Om) hoping I can do something worthy of a blog post

zane17:06:51

@gary: What's the idea there? Just that there isn't a significant enough perf gain by rendering the initial app state on the server?

hlship18:06:46

So, in reagent, I'm still trying to wrap my head around one aspect of form-2 component functions (function that returns a render function).

hlship18:06:13

The docs mention that you have to declare the same set of parameters in both functions.

hlship18:06:46

I would assume that's because the Reagent hiccup syntax sees [my-func :a :b] and invokes (my-func :a :b)

hlship18:06:13

And the returned render function takes the place of the original function.

hlship18:06:15

Or something.

hlship18:06:32

And then that new function has to be invoked to render the actual (hiccup) content.

hlship18:06:06

But I kind of don't get why that function needs the parameters AND I totally don't get the bit about the render function being re-invoked with different data, later.

hlship18:06:11

I mean, I guess it's related to Reagent atoms & subscriptions, So if a subscription changes, the render function is re-invoked. But why would any of the parameters be different at that point? And if not, why are they even needed?

borkdude18:06:34

@hlship: excellent question. All I know is that the component re-renders when the props (args) change or the subscribed atom(s) change. If setup state (that the component closed over) would also change because of props, how would that work...

borkdude18:06:08

@hlship: I'm going to try it out with some logging

borkdude18:06:48

what does figwheel mean or is it a made up word? and side-car?

nullptr18:06:43

figwheel: @$%!ing insanely great, wheeeeeeee lein [plugin]

borkdude18:06:55

@dnolen: watched it, did he explain where the word came from?

dnolen18:06:07

@borkdude: I don’t think so

dnolen18:06:25

@borkdude: ha if you search for Fig. Wheel on Google you get a bunch of car diagrams

teslanick18:06:25

I thought I read somewhere that it was a portmanteau/play on words with repl somehow. Maybe that's weasel, though.

dnolen18:06:22

sidecar is a motorcycle thing

borkdude18:06:38

so that's probably wordplay? or is that a technical term for some side process running

borkdude18:06:42

@hlship: I made an example that shows what happens https://www.refheap.com/102131

gary18:06:24

@zane: the idea is that html templating gets messy and slow when the application state starts getting complicated

borkdude18:06:11

@hlship: When you pass a prop and initialize local state and rely only on that local state to display stuff, you won't see a changed prop. if you use it directly you will

borkdude18:06:42

@hlship: for example, the local atom x will only be initialized once

borkdude18:06:38

but you will see a new re-render for prop changes

borkdude19:06:08

@hlship: there is also some documentation about the difference between [foo x] and (foo x)

zane19:06:48

@gary: Oh. I see. You're talking about switching over to React for the first time?

borkdude19:06:49

@hlship: here are some useful resources (I'm not suggesting to use this framework though, didn't look into it myself): https://github.com/Day8/re-frame/wiki

nullptr19:06:35

figwheel: fast, interactive goodness which helps eval expressions lickety-split

borkdude19:06:11

figwheel: because I enjoy eating figs while behind the cljs steering wheel

nullptr19:06:35

it just makes sense

gary19:06:05

@zane: yes, I'm also interested in helping other Java/Spring developers out of the tarpit

zane19:06:16

Good man.

gary19:06:39

Angular is getting some traction at my dayjob, so once people get comfortable with SPAs I'm going to go to the managers and say "hey this Angular thing is great but I know this other thing that leverages the JVM." they'll always pick a technology that has java in the description over anything else

akiva19:06:37

Brilliant.

borkdude19:06:04

getting to clojurescript the hard way

gary19:06:21

but first I need to be an expert in it and have an elevator pitch style answer for every little question anyone has

nullptr19:06:59

gary: start working on your GWT talking points 😉

lunar19:06:07

@gary: :thumbsup: lol

agile_geek19:06:28

@gary my current client have rejected Angular as ‘too opinionated’. They are more open to React as they prefer it’s paradigm. However, given their conservative nature I suspect Reagent or Om would be several steps too far!

akiva19:06:09

You have a client that knows the difference?

agile_geek19:06:17

@akiva: one fairly clever JS developer who has the ear of the right people!

akiva19:06:28

Outstanding!

dnolen20:06:00

@martinklepsch: I take it the codemirror addons haven’t yet been bundled with the codemirror cljsjs JAR?

mfikes20:06:17

Linux fans: A demo of REPL into iOS: https://youtu.be/IyPvEY97i3k

hlship21:06:10

@borkdude So my guess is that if you had something like:

[my-component @(subscribe [:foo])]
And my-component is a form-2, then it will be invoked directly once (with the :foo value), then the returned renderer will be invoked once (again, with the current :foo value), then the returned renderer will be invoked again when the value of :foo changes. Anyway, that's my guess as to what's going on. My point is that it feels like the form-2 function should capture its parameters, and the renderer should always be invoked with no parameters.

borkdude21:06:25

you can use the initial props to set up local state, but that's only before the component will be mounted

borkdude21:06:53

next time you pass other props the component will only be re-rendered. that's why you have to use two times the same arity I guess

hlship21:06:17

Meanwhile, I'm liking the concepts behind re-frame.

hlship21:06:33

@borkdude: Not to be pedantic, but looking at https://www.refheap.com/102131, it seems like the component generated from hello-world will always re-render when app-state changes, so there's no chance for the form-3 component to re-render "in place". I think that would hold not just for the [:p "App Sate " @app-state] element, but also for the [form-3 @app-state] itself ... the process of providing a new value from an ratom should, as I understand it, invalidate the outer component as well a the inner one ... but perhaps I'm underestimating Reagent's cleverness. I haven't looked at the code yet.

hlship21:06:05

And, to be honest, it doesn't matter that much for a mostly-crud app like I'm currently working on. Maybe something with a lot of charts/graphs/graphics it would be different.

borkdude21:06:14

@hlship: there is a chance for the form 3 component to re-render in place: when you hit its button

hlship21:06:56

ok, I'll buy that.

borkdude21:06:27

@hlship: usually you don't really need to worry about re-rendering

hlship21:06:18

I think you're right ... I'm just trying to wrap my head around things conceptually. I'm finding that a lot easier with React than with, say, Angular.

borkdude21:06:38

@hlship: it's fairly easy to track the re-rendering of components in Reagent

borkdude21:06:45

@hlship: just add a couple of printlns

markstang22:06:38

@hlship don't forget the debuggers and source maps

martinklepsch23:06:26

@dnolen: addons as in language modes?

dnolen23:06:47

@martinklepsch: no addons like bracematching, closebrackets etc.

martinklepsch23:06:27

@dnolen: ah. Not that I'm aware of.

dnolen23:06:53

@martinklepsch: seems like something simple enough to add given you guys already have the modes sorted out

dnolen23:06:19

btw the experience of using CodeMirror today through CLJSJS was really good, way better than I ever had it in JS simple_smile

dnolen23:06:38

addons bit was the only trouble I encountered