Fork me on GitHub

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


@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


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


My experience has been with, 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 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


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


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.


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?


@grav Yes, this is close to it


@lifecoder I think also has a few of those.


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


is there a reference frontend/backend 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...


@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.


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


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


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


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


@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


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


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


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


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


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


@raspasov We had the 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 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.


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?


just created & attached a patch to that ticket


@rgdelato can you try again with current master? 🙂


please report back any feedback!


Thank you both for all your hard work!


...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"]?


@rgdelato no you need to build from source


okay, cool. I'll give that a try


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


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


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


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 printSummary
WARNING: 0 error(s), 1 warning(s)


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


not a core.async problem


use 1.9.473 for now


thanks Antonio


1.9.473 still failing - moving back to .293