Fork me on GitHub
#clojurescript
<
2017-03-27
>
nikki04:03:31

when you make something with (new ...) using a thing you made with (deftype ...) is its storage implemented with persistent immutable stuff?

raspasov06:03:53

@U06HTKDMF in Clojure I know that (deftype …) is effectively a final Java class, no data structures beyond that for max. performance; I would be curious to know what ClojureScript does if you dig into it

raspasov05:03:00

@tbaldridge @mikethompson @anmonteiro great discussion in general btw about the trade-offs of different libs

raspasov05:03:10

My experience has been with om.next, and most recently one great thing that I’ve been utilizing is the “client-queries-as-a-server-api” possibility where I send the client queries to the server, use core.match on the server to parse them there and send back the appropriate part(s) of client state. And I’m using Postgres on the backend! (even though, arguably, Datomic would be effectively ideal, since it will eliminate the majority of accidental server-side data transformation code) The conversion from om.next query data -> honeysql SQL query data has been mostly pain-free; no more REST-like madness like /update/this/id/1, /save/that, /get/products, etc; but even beyond that the biggest win for me is the effective “de-duping”/”merging" of HTTP requests or WebSocket messages; the “app launch/initializing” logic has always been super hairy in all projects that I’ve done before but now it’s effectively gone. You either had to manually enforce “one request at the start of the app only!” or coordinate a bunch of requests “in-flight” via some core.async wizard skills; it’s never pretty; Let’s say I need “products”, “account”, and “categories” data at app launch; that’s sent as one request(!), and I didn’t have to do any work to make that happen; the only part I had to do was writing a server-side core.match destructuring logic but that’s literally 100 lines or so; maybe when I flush out the idea more it can be a library one day; in any case, if you use Datomic that won’t be needed

raspasov05:03:35

So I effectively have one endpoint for most things - /parse-om-query

gklijs06:03:49

By default deftype is immuatable, but you can define mutable elements in a type, but this does at the same time make the elements only private accessible, so you need to add getters/setter methods by using a protocol. For the javascript parts it’s almost the same, but you can also mutate the data in a normal deftype, but this is because javascript don’t have immutable data types. So in javascript you can use a set! on a type, while in java you can’t.

lifecoder08:03:25

Looking for a library/framework for clojurescript in functional reactive style like cycle.js. Does anyone know if this exists? Or maybe an extension to one of the popular clojurescript frameworks?

lifecoder09:03:54

@grav Yes, this is close to it

rauh09:03:41

@lifecoder I think http://github.com/funcool also has a few of those.

lifecoder10:03:04

@rauh thanks, lots of cool stuff there, even library similar to rxjava

mping10:03:04

is there a reference frontend/backend om.next app? I dabble in om but found I had to write alot of boilerplate, didnt help I was learning clojure… There’s #untangled but I dunno how useful it is...

rauh10:03:33

@lifecoder Unpopular opinion: You might not need any of those reactive/stream approaches. I'm currently writing a large SPA and I'm all synchronous code. Much easier. Anything remote will be put into data after 1-2 "hops" of async Promise. After which I'm back to synchronous.

rauh10:03:17

@mping Don't start with Om.next if you're new to clojure. Go with old om, reagent, rum or quiesent.

mping10:03:11

@rauh Im not new to clojure, but there’s alot to learn 😄 I’ve done stuff with reagent already, enjoy it but om.next seems interesting

tbaldridge12:03:07

@rauh, how do you have synchronous code in JS?

tbaldridge12:03:40

Or are you saying "limited async for network calls, the rest is sychronous"?

rauh14:03:33

@tbaldridge Yes that's what I meant. Any state changes/event don't happen async. Every now and then I'll use goog.async.nextTick

mikepence14:03:59

appreciate the discussion regarding clojurescript libraries and their trade-offs. good to know that both om.next and reframe are viable solutions.

isak14:03:38

I think this is the best part of Om.next. I've been using this kind of API from re-frame for client-server communication, and it works great there too.

raspasov15:03:38

@isak that’s good to hear 🙂 just curious, how does a re-frame “query" look like or you made your own in some form?

dnolen16:03:48

@isak I agree, for various reasons using re-frame recently on something and we just did an om.next approach with Datomic - works great

dnolen16:03:42

I think the simplifying approach is more important than which library you use - though of course I’ll put my vote for om.next 😉

isak16:03:23

@raspasov We had the Om.next query -> SQL already handled for queries and updates, so we just made an event handler, effect handler, and subscription to make that as convenient as possible. Some places, for example, we subscribe to an om next query, that then gets executed on the server, and the result sent down (returns a :pending state in the meantime). Then that data gets wiped when the subscription is disposed. So it is kind of similar to om.next in that the query can be colocated with the component, the difference of course is that it cannot be composed from the component hierarchy. Usually, for more permanent data, we trigger it from an event, so we have an effect handler called query-next-giving-id, which does the query, and places the data in a predicable place people can subscribe to.

rgdelato18:03:52

I'm trying to test out using :npm-deps in a basic figwheel project and I'm getting ^--- The key :npm-deps is unrecognized. Is there any documentation on what else I need to update?

anmonteiro18:03:26

just created & attached a patch to that ticket

anmonteiro19:03:02

@rgdelato can you try again with current master? 🙂

anmonteiro19:03:08

please report back any feedback!

rgdelato19:03:48

Thank you both for all your hard work!

rgdelato19:03:52

...sorry if this is a dumb question, I'm still on the newer side to cljs. What do I set my dependency to to get master? Is it just [org.clojure/clojurescript "master"]?

dnolen19:03:09

@rgdelato no you need to build from source

rgdelato19:03:32

okay, cool. I'll give that a try

rgdelato20:03:06

key is still unrecognized for me after building master and updating my clojurescript version, but I'm still digging into it to make sure I'm not making some obvious mistake

dnolen20:03:18

@rgdelato make sure you clean, i.e. rm -rf target etc

dnolen20:03:32

the REPL will tell you what version of ClojureScript you are running too

ag22:03:07

there’s a warning though:

..../1wwo/-6u3tlw/js/main.out/cljs/analyzer.js:4996: WARNING - incomplete alias created for namespace cljs.spec
var mchk = (function (){var and__5243__auto__ = cljs.spec;
                                                ^

Mar 27, 2017 3:32:16 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)

anmonteiro22:03:11

@ag do you have core.async in that project?

anmonteiro22:03:31

not a core.async problem

anmonteiro22:03:34

use 1.9.473 for now

ag22:03:36

thanks Antonio

ag22:03:22

1.9.473 still failing - moving back to .293