Fork me on GitHub
#clojurescript
<
2017-02-02
>
sova-soars-the-sora02:02:47

Hi all, I'm trying to update some things in my atom after I get a serversent message via sockets. My question is: what is the idiomatic way to merge in novelty?

sova-soars-the-sora02:02:18

I am using naive swap!s to adjust the atom state, but not every affected component is re-rendering... must I always use om/transact! ?

anmonteiro02:02:52

@sova there's om.next/merge! which is probably what you're looking for

anmonteiro02:02:56

there's also an #om channel where more people can help you

spacepluk08:02:57

has anybody done any performance comparison between spec and schema?

spacepluk08:02:54

so the next question, is there any lib to transform schema specs into spec or truss?

Aron08:02:22

how do you serialize objects to show in console log? json?

thheller09:02:32

@ashnur if you just want to log cljs objects and be able to inspect them in the console https://github.com/binaryage/cljs-devtools is the way to go

thheller09:02:48

otherwise pr-str or clj->js

thheller09:02:13

cljs-devtools only works in chrome though

thheller09:02:56

(enable-console-print!) and (prn my-obj) works as well

Aron09:02:10

i use chrome (at least for now, i wish there were better browsers though)

Aron09:02:35

thanks, will look those up 🙂 i bet half of them does the same thing with minor differences?

thheller09:02:08

the devtools stuff just teaches chrome about cljs objects so they can be inspected like normal js objects

Aron09:02:17

i used (enable-console-print!) but with (pprint)

Aron09:02:27

yeah, that sounds great

thheller09:02:37

yeah that is just printing, useable but devtools is better 😉

Aron09:02:35

hah, i even have devtools.preload in my :preloads

Aron09:02:04

guess i found it but then gave up before i figured it out fully

Aron09:02:46

it works!

Aron09:02:09

not with pprint though, but with (log js/console ...)

Aron09:02:08

how to have the short log function?

thheller09:02:00

(js/console.log ...) is the shortest non-macro way

thheller09:02:50

there are some libs that have a (log ...) macro but that requires a :require

pesterhazy09:02:23

it's useful to call console.log directly because chrome knows the location of your log message in the code then

Aron09:02:03

i see, thanks

Aron09:02:29

if i have a range of numbers, what's the fastest way (i actually care more about the performance this time than anything else), to do a cartesian product with itself but each element from the resulting list of pairs is only kept based on a probability function. normally i would create the whole list and remove elements from it, but because of performance, I should probably do it the other way around?

Aron09:02:53

i like nice clojurescript errors such as: "java.lang.OutOfMemoryError: Java heap space"

thheller09:02:14

that is a java error, probably the compiler. usually a sign of an infinite loop

Aron09:02:36

it's not my code, coming from a library, but i don't care, i already removed it

thheller09:02:39

you can give it more memory to see if it completes

Aron10:02:02

i definitely will not do that. i would rather never ever touch either clojure or clojurescript than to have to go there ever again.

Aron10:02:31

the only reason i am using jvm now is figwheel with lein

thheller10:02:19

not that painful

thheller10:02:55

but the compiler should never require this much

Aron10:02:09

i don't have the time and patience for java/jvm issues

Aron10:02:41

and frankly, the biggest mistake was to base clojure on jvm, that i will never understand

thheller10:02:13

well to me that was the biggest plus

Aron10:02:21

guess there were not many options, and all the others would've been harder or would've brought less fame/money

Aron10:02:01

i remember that I saw something performance related in clojure/script

Aron10:02:13

if i want to do something fast how to do it, but i can't find it

rauh10:02:14

There is a goog.math.Matrix namespace if you're ok with workign with JS arrays

Aron10:02:18

it was some kind of wrapping in and out

Aron10:02:24

checking

thheller10:02:23

javascript has a bunch of native things that might be of use

Aron10:02:38

i know js. that's where i am coming from. once i wrote a bigint lib using typedarrays.

Aron10:02:07

just to see how fast they are compared to arrays :))

Aron10:02:47

for multidimensional data i would definitely use this in javascript https://www.npmjs.com/package/ndarray

Aron10:02:58

too bad clojurescript loves java more than npm

Aron10:02:56

but this is more like just being able to do fast loops and read/write data, mutate stuff, not multidimensionality

Aron10:02:15

"CLJS DevTools internal error: TypeError: pred.call is not a function" (i know that most of the errors I encounter are because I don't yet know what I am doing, but the error messages do not help much either to find it out :)) )

Aron10:02:11

although reimplementing it instead of using it is ridiculous

Aron10:02:39

now can I use the ndarray modules with this? 🙂 https://github.com/scijs/ndarray/wiki/ndarray-module-list

thheller10:02:12

@ashnur if I had to guess it is probably trying to log something lazy causing the error to appear "devtools internal" vs in your code

Aron10:02:46

i figured it out since, i put the docstring in the predicate in the wrong place, you can't call a string as a function

Aron10:02:02

or at least that's what i think was trying to say

stuartrexking11:02:10

What’s a good way to include npm dependencies in a project? Say I’m using lein, would I use npm to save the deps and then load them using lein? How to other developers approach this?

stuartrexking11:02:41

There is this https://github.com/RyanMcG/lein-npm which seems to exactly what I want.

stuartrexking11:02:20

Just wondering if there is a standard or idiomatic way to manage npm deps.

thheller11:02:28

@stuartrexking there was a lot of new stuff in the recently release 1.9.456, lots of changes coming with regards to npm

stuartrexking11:02:43

Yeah, but none of it around dependency management.

stuartrexking11:02:05

It’s all great for loading the libs once you have them, but how do you manage fetching the deps etc.

thheller11:02:06

that is probably going to be left to npm

thheller11:02:11

ie. write a package.json

thheller11:02:32

and use npm directly

darwin12:02:38

@ashnur internal CLJS DevTools errors are usually caused by exceptions raised during printing of your data structure, e.g. buggy implementation of some protocols used during printing or bad data shape. You should see full stack trace when you expand the internal error log message. That would be more helpful to reason about your issue.

tomaas12:02:05

Hi, when using reagent project template, I use lein fighwheel. However, if I change something in server side, I need to C-c and lein fighwheel again to see the changes. What is a better/appropiate way to do this?

darwin12:02:58

You could try to adopt the reloaded workflow[1], but that would require you to write reloadable code and use reloadable libraries [1] http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded

dnolen13:02:36

@tomaas you can also use Component to configure your Web Server + Socket REPL Server Clojure & ClojureScript (Figwheel)

dnolen13:02:50

this is what I do

tomaas13:02:20

ok, I'll try setup it, thanks @dnolen

dnolen13:02:02

figwheel-sidecar works great as a stand-alone library

Aron13:02:46

i have (.forceSimulation js/d3) working so far, but I am guessing the chain stuff would look bad if I tried

dnolen13:02:44

(.. js/d3 forceSimulation (force “center” …) (force “link …) …)

dnolen13:02:59

.. can be used for chaining

Aron13:02:11

what's the name of ..?

Aron13:02:12

and thanks, that should work

dnolen13:02:13

I don’t know if there is a name other than “dot dot"

dnolen13:02:39

it’s a macro that expands to nested dot operations

bhauman15:02:44

@tomaas the other think to do here, is get editor attached repl working

bhauman15:02:04

so you can reload your server side code via the repl

bhauman15:02:22

in emacs with cider this is very straightforward

bhauman15:02:25

I'm sure its straightforward in cursive as well

olivermooney16:02:00

@sveri belated thanks for that stuff about Om & Reagent earlier, got called away from the keyboard. I’ve used Rum in combination with statecharts and a hodgepodge of individual libraries so I’m keen to see how a more integrated app foundation could work, & it seems that comes down to a choice between reframe and Om.Next

emccue19:02:21

Is there an up to date tutorial for using the new npm module resolution with figwheel and friends?

dnolen19:02:11

not for Figwheel specifically but there isn’t any need

dnolen19:02:29

it’s also alpha quality stuff with many sharp edges 🙂

dnolen19:02:45

we already know that Closure Compiler will need changes for it to be practical

dnolen19:02:07

and we need a lot more changes to ClojureScript for it to be easy

richiardiandrea20:02:36

has anybody ever made externs for Object.defineProperties, how does this look like?

var IntersectionParams = {
  "TYPE": {
        "LINE" : {},
        "RECT" : {},
        "ROUNDRECT" : {},
        "CIRCLE" : {},
        "ELLIPSE" : {},
        "POLYGON" : {},
        "POLYLINE" : {},
        "PATH" : {},
        "ARC" : {},
        "BEZIER2" : {},
        "BEZIER3" : {}
    }};

dnolen20:02:18

@richiardiandrea I don’t understand how is that related to Object.defineProperties?

dnolen20:02:32

@richiardiandrea I’m pretty sure that using Object literals like that won’t work

dnolen20:02:41

I would refer to Closure docs here

richiardiandrea20:02:10

@dnolen yeah I tried to have a look there, fuzzy results, but I'll search more

dnolen20:02:42

you could do that … or

dnolen20:02:49

Object.LINE; will work

richiardiandrea21:02:08

oh well, we are practical right? 🙂

richiardiandrea21:02:57

basically I need to be sure that TYPE.LINE works fine...it looks like your solution is good, will report back

dnolen21:02:37

Object.TYPE; plus my previous thing is all you need for TYPE.LINE to work