Fork me on GitHub
#clojurescript
<
2017-07-16
>
ajs08:07:04

@mobileink i've personally never been a big fan of material design, it makes things look either like Android or a Google service

ajs10:07:56

i'm having an odd problem since upgrading from an old version of cljs, when using :advanced. I use long.js (https://github.com/dcodeIO/long.js) and there is a

.toNumber
function on the objects it returns. This function works fine in :simple opts but returns NaN in :advanced. I call it like
(.toNumber .....)
has anything changed with respect to how you call member functions like this that I'm i'm missing?

ajs10:07:45

i wonder if somehow there is some name mangling going on. I do have an externs file for long.min.js

thheller10:07:35

but no nothing in that regard has changed

ajs10:07:39

i don't know, this is an old codebase so perhpas that should be changed

ajs10:07:42

that good library looks like an identical api

thheller10:07:44

> long.js - A Long class for representing a 64 bit two鈥檚-complement integer value derived from the Closure Library for stand-alone use and extended with unsigned support.

thheller10:07:50

I would expect so 馃槈

ajs10:07:21

i assume those goog libraries are automatically :advanced compatible with externs implicitly handled?

thheller10:07:38

they don鈥檛 require externs at all

ajs10:07:51

i'm simply (:import [goog.Math.Long]) without any change to project.clj and then just use the api like an ordinary js library?

ajs10:07:15

er, lowercase math

thheller10:07:57

(:import [goog.math Long])

ajs10:07:59

how does the namespacing work on that when I call those functions, i.e. the constructor for "new Long" is currently (.-Long js/dcodeIO) -- would it be (.-Long js/Long) or something like that?

qqq10:07:04

I need websockets. Is https://github.com/jarohen/chord the library to use, or something else? the two sides are clj and cljs

ajs10:07:52

so the goog.X stuff just goes into the global ns

thheller10:07:16

hmm? the :import does that

thheller10:07:21

and its not global

ajs10:07:32

i get it now

ajs10:07:38

i'm not so well-versed on raw JS stuff

ajs10:07:21

wow, that's awesome @thheller worked like a charm in :advanced

ajs10:07:36

note to self: always look at Closure libraries first

Takis_13:07:41

hello 馃檪 , using mongodb/mongoose/node.js/express etc from clojurescript its easy? or you have to use clojurescript libraries?

pesterhazy14:07:33

you can just use any javascript library from clojurescript

pesterhazy14:07:15

no wrappers needed mostly

pesterhazy14:07:27

roughly anything you can do in javascript, you can do in cljs

pesterhazy14:07:38

though ES5 example may be easier to translate

renan14:07:28

@pesterhazy @takis_ I pass now this problem... I want use npm React component in my re-frame project... No success yet... I tried use lein-npm, but when i run nodejs/require "module", in browser require is undefined 馃槙 馃槄

ajs14:07:31

i noticed that cljs is missing from this popular benchmark: https://github.com/krausest/js-framework-benchmark if I had the time I'd take a stab at it

henrik15:07:06

@ajs That would be nice for reference! But it鈥檚 probably not a huge loss. Clojure/Script is after all a language created to improve performance after the threshold at which cognition, rather than computing resources, becomes the performance bottleneck.

ajs15:07:09

@henrik true. that's also true of Elm and some of the other items in that benchmark. I mentioned this only because someone asked me why cljs wasn't on there.

Takis_16:07:21

thank you 馃檪

renan17:07:52

@pesterhazy @takis_ have you examples the clojurescript using express, or other npm library?

Oleh K.17:07:31

I'm trying to make a plugin for LightTable and can not save settings. I don't understand why my state atom has nils in ::on-close-destroy behavior: https://github.com/okilimnik/renatal-lt-plugin/blob/master/src/lt/plugins/renatal.cljs

Oleh K.17:07:46

Can anybody help?

renan17:07:55

@pesterhazy Oh! Thanks! But this example use express of npm package?... Because this is my problem, I want use a react component by npm... But I don't got yet

pesterhazy17:07:40

yes it uses the npm package

alice17:07:12

Does anyone know if a Clojurescript version of dom-to-image exists?

alice17:07:50

I'm trying to generate page previews and I'm lost

renan17:07:49

@pesterhazy oh... Ok... But this equal for using another npm package ? For example, how to install anda import this package https://www.npmjs.com/package/@atlaskit/button in my project? You have another example of this ? Or links about this?

anmonteiro18:07:38

@alice what version of CLJS are you using? 馃檪

anmonteiro18:07:05

so you can use :npm-deps

anmonteiro18:07:13

just tried it and it worked

anmonteiro18:07:19

@alice

;; build.clj
(require '[cljs.build.api :as b])

(b/build
  "src"
  {:optimizations :none
   :main 'foo.core
   :npm-deps {:dom-to-image "2.5.2"}
   :closure-warnings {:non-standard-jsdoc :off}
   :compiler-stats true
   :parallel-build true
   :asset-path "/out"
   :verbose    true
   :output-dir "out"
   :output-to "out/main.js"})

anmonteiro18:07:44

where foo.core is:

(ns foo.core
  (:require [dom-to-image]))

(enable-console-print!)

(println "Use dom-to-image:" dom-to-image)

anmonteiro18:07:27

thanks to Closure Compiler JS module processing you can just use its functions too: (dom-to-image/toPng ...)

anmonteiro18:07:39

^ all this module support works in 1.9.671, and it鈥檚 greatly improved in the version to be released this week, as per: https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules

alice18:07:04

Woah, that's dope

alice18:07:19

I didn't know that could work

anmonteiro18:07:35

it still feels like magic to me too

alice18:07:36

What if I happen to use lein rather than boot, though?

anmonteiro18:07:56

@alice where do you see Boot?

alice18:07:30

I figured the (b/build bit signified boot, never seen that in my project.clj

anmonteiro18:07:51

hah, no. That鈥檚 using a simple Clojure script to interact with the ClojureScript API

anmonteiro18:07:01

(`lein-cljsbuild` calls cljs.build.api/build for you)

anmonteiro18:07:10

there鈥檚 no build tool involved in my example

anmonteiro18:07:23

just drop the relevant compiler options in your CLJS compiler options

anmonteiro18:07:32

this should be build tool agnostic

anmonteiro18:07:59

let me know if you run into any problem

pesterhazy18:07:40

I'm curious, what's dom-to-image useful for?

anmonteiro18:07:08

looks like it takes SVG / PNG captures of a web page

anmonteiro18:07:13

or rather, a DOM node

anmonteiro18:07:45

I never used it before, but was curious to see if it worked with the JS module processing 馃檪

anmonteiro18:07:49

turns out, it does

pesterhazy18:07:58

@alice, I'm curious why you (or other) take screenshots of dom nodes from javascript

alice18:07:21

I'm trying to make thumbnails to pages from links

alice18:07:39

i.e I link to a youtube page and it'll show an image of the page

alice18:07:51

If you have better alternatives I'd love to hear

pesterhazy18:07:48

aren't there service for this? I'd use a service (if I had a budget)

alice18:07:00

Same, I think

alice18:07:15

I'm really homebrewing this shit to all hell

pesterhazy18:07:20

seems like a job for an API to me

anmonteiro18:07:36

there鈥檚 also the open graph metadata that Youtube probably sends

anmonteiro18:07:44

<meta property="og:site_name" content="YouTube">
<meta property="og:url" content="https://www.youtube.com/watch?v=wZZ7oFKsKzY">
<meta property="og:title" content="Nyan Cat 10 hours (original)">
<meta property="og:image" content="https://i.ytimg.com/vi/wZZ7oFKsKzY/hqdefault.jpg">

alice18:07:56

I guess alternatively

alice18:07:00

I could use IFrames

alice18:07:11

They'd probably be slower but more useful and all encompassing I guess

alice18:07:20

does anyone know if Reagent supports IFrames

ajs19:07:13

can anyone recommend a good protobuf library for front-end, preferably nice with cljs?

thheller20:07:39

> note to self: always look at Closure libraries first