Fork me on GitHub
#clojurescript
<
2017-01-27
>
okeydoke00:01:30

hey guys, anyone know the editor/ide David Nolen is using in this talk?

anmonteiro00:01:25

without knowing which talk, I'm gonna guess Cursive

tanzoniteblack00:01:16

looks like cursive

okeydoke00:01:22

ok thanks guys

theophilusx00:01:13

Given he is using nodejs, it could be atom

fellshard00:01:15

Naw, the REPL is an unanchored window and has IntelliJ icons. That's probably Cursive.

cfleming00:01:52

It’s definitely Cursive

tanzoniteblack00:01:04

but all of the things he's doing can be done in any clojure supporting IDE that allows you to interact with the repl by sending code over: cursive, proto-repl, cider, lighttable, etc

theophilusx00:01:51

Yep, I think that is one of the things I like about clojure and clojurescript - you are not locked into a specific tool chain. Nearly any editor of choice which supports a subprocess can be setup with a repl and the majority of them also support some form of 'overlay' which can provide temporary eval output in your code window

okeydoke00:01:38

Ah ok thanks, new to clojure/script having some issues with sublime text and setting up a REPL so looking for an alternative

theophilusx00:01:38

Which other editors are you familiar with and what is your main target (clojure, clojurescirpt, nodejs etc)?

okeydoke00:01:47

I mainly just use sublime text for frontend and serverside javascript, looking to try out clojurescript

tanzoniteblack00:01:22

if you're just playing around with clojurescript to see what it's like, you might try http://nightcoders.net/ ; I've never actually used it before, but it's a web IDE for clojurescript that's all set up for you already

okeydoke00:01:50

Thanks! thats pretty cool

mj06:01:44

Starting with clojurescript, just went through channel history. Found few libraries to work with, but can someone please share some other resources to get started with better setup, debugging or any other templating library and if possible please pin those resources to this channel, it would be really helpful, thanks

rauh06:01:44

@mj Most people just choose their React wrapper like Reagent,Om,Rum (etc) and then start coding away. In a pretty large SPA I use only 3 libraries: Rum, Bidi, Datascript. Other functionality I need is all taken from Google Closure which ships with CLJS.

mj06:01:17

rauh Cool, will go through it, thanks! simple_smile

benzap15:01:49

@mj fastest way to get started would probably be to use the chestnut template https://github.com/plexus/chestnut It provides you with most of the things that @rauh suggested, and is kept up-to-date by the maintainer

mj16:01:52

benzap: Thanks! I like chestnut template. I’ve used it before as well, but now I’m using rum instead of Om as @rauh suggested simple_smile

plexus12:01:47

@mj I would accept a PR to add a +rum flag to Chestnut 😉

dnolen16:01:09

I’m deprecating the ClojureScript wiki, please direct all edits to the ClojureScript site, thanks https://github.com/clojure/clojurescript-site

pbaille17:01:23

I would like to create a type that behaves exactly like a regular cljs vector but with some additional protocol implementations. What is the best way to go for doing so?

dnolen18:01:10

you can safely extend instances with specify

dnolen18:01:14

so you could make a new constructor

dnolen18:01:25

(defn my-vec [] (specify [] …))

dnolen18:01:58

specify is just like reify in usage beyond the first argument being the thing you want to extend

pbaille18:01:21

ok I see, I will try that, thank you

pbaille18:01:57

And if I want a new concrete type that inherits from vector? is there a straightforward way or am I supposed to do a big deftype?

pbaille18:01:34

if so, how can I know all the protocols to implement?

pbaille18:01:24

in clojure I use this function from “programming clojure”

(defn scaffold
  "Given an interface, returns a 'hollow' body suitable for use with `deftype`."
  [interface]
  (doseq [[iface methods]
          (->> interface
               .getMethods
               (map #(vector (.getName (.getDeclaringClass %))
                             (symbol (.getName %))
                             (count (.getParameterTypes %))))
               (group-by first))]
    (println (str " " iface))
    (doseq [[_ name argcount] methods]
      (println (str " " (list name (into '[this] (take argcount (repeatedly gensym)))))))))

dnolen18:01:40

there’s no way to do anything like that

dnolen18:01:48

you either need wrap vector or use specify

pbaille18:01:04

you mean wrap vector in a deftype?

pbaille18:01:15

that’s what i’m planning to do but I don’t know exactly what protocol to implement.

dnolen18:01:59

I’m saying there’s nothing easy here

dnolen18:01:13

you have to go study persistent vector and implement everything

dnolen18:01:21

the fact that it is challenging is not a problem

dnolen18:01:31

since we don’t care that this is hard to do

pbaille18:01:11

may I ask why 🙂 ?

dnolen18:01:29

why we don’t care? we just don't

pbaille18:01:39

ok I see 🙂

pbaille18:01:09

thank you for all I will dive into PersistentVector

dnolen18:01:26

the amount of value to be gained from making it easy doesn’t outweigh the time wasted on doing something few people will ever use

dnolen18:01:40

that and I don’t want to make it easy

dnolen18:01:46

so there’s little point on working on it 🙂

pbaille18:01:09

ok that’s clear

Rohit Thadani18:01:58

are there any examples out there where published es6 components(those that extend React.Component) have been used in reagent/re-frame. I am having a really difficult time finding one. Without this I'd just be forced into using the traditional javascript to build the app which i really dont want to do.

peterschwarz18:01:36

@rohit_ you can try the #re-frame channel - they are a bit more focused on the specifics of your question

pbaille18:01:41

I’m trying to write a macro that yields different code depending on if it’s called from clj or cljs. how can i do this correctly within a cljc file?

moxaj18:01:58

@pbaille (boolean (:ns &env)) returns true when compiled in cljs

uwo19:01:38

namespaced maps haven’t landed in clojurescript yet have they? I’m getting errors on latest when I try

dnolen19:01:27

literals should work, but not reader support

uwo19:01:14

hm. I’m using version "1.9.293"

7h3kk1d19:01:14

Woah, I didn’t even know about namespaced maps

anmonteiro19:01:04

@uwo please share if you have something minimal to repro your errors

uwo19:01:07

and I get this error adzerk.boot_cljs.util.proxy$clojure.lang.ExceptionInfo$ff19274a: Reader tag must be a symbol when trying something like #::dropdown-panel{:help-text "hidiho"}

uwo19:01:44

right. I suppose I should go make a bare cljs repo. sorry to bother

uwo19:01:00

I see. my example is using a reader

anmonteiro19:01:33

@uwo doesn't seem like a bug

anmonteiro19:01:54

in your example ::dropdown-panel should be an alias for another namespace

anmonteiro19:01:14

otherwise you should use #:dropdown-panel {:help-text "hidiho"}

uwo19:01:09

correct. that alias exists in the namespace in which its used

anmonteiro19:01:20

@uwo in any case this works for me:

Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[clojure.string :as str])
nil
cljs.user=> #::str{:name "asd"}
{:clojure.string/name "asd"}
cljs.user=>

peeja21:01:50

Given there's no alter-var-root, is there a way to rebind a var from another namespace?

peeja21:01:18

(I know how terrible that question sounds…)

jr21:01:52

bindings

peeja21:01:47

@jr What's that?

peeja21:01:20

Oh, binding

peeja21:01:27

No, not dynamic binding

jr21:01:28

yeah my bad

peeja21:01:44

Actually mutating the var

jr21:01:02

why do that?

peeja21:01:25

I need to tweak some things in my devcards environment

peeja21:01:00

Specifically, we have feature flags I need to fiddle with

peeja21:01:21

It's not a great situation, but I'd rather not drop everything to rearchitect our feature flag system right now just to add a devcard 🙂

darwin21:01:56

in dev mode you can simply go and change it using javascript interop, no?

anmonteiro21:01:38

@peeja hrm... (set! my.ns/foo 42)?

peeja21:01:46

Yeah, that might be the thing to do

darwin21:01:49

or (aset js/my_ns “my_var" 42)

peeja21:01:49

Oh, right

peeja21:01:04

set! actually pretty nice here

dnolen21:01:21

ClojureScript 1.9.454 release is imminent 🙂

dnolen21:01:42

well assuming build box issues get sorted, heh

sherbondy21:01:01

Looks like a game-changer, especially for newcomers to CLJS ecosystem, awesome way to kick off the new year! Can’t wait to give the CommonJS module support a spin.

dnolen21:01:10

it’s a work in progress for sure

dnolen21:01:20

but lots of potential

sherbondy21:01:34

Have to start somewhere! Congrats on cutting a release.

sherbondy21:01:26

( JS module ecosystem craziness doesn’t make the job particularly easy 😛 Have your work cut out for you.)

dnolen21:01:02

fortunately once again we mostly get to take advantage of the fact that somebody else had this problem before us

ag22:01:23

anyone who uses cljs-devtools, when you have a breakpoint (say I placed (js* “debugger;”) somewhere). it stops. now when I type n Chrome Dev console - intellisense works extremely slow and kinda jittering. Is there a way to fix that? annoying me badly

anmonteiro22:01:12

it takes a while for the JAR to be available in Maven Central, right?

anmonteiro22:01:20

like 30 min or something?

mfikes22:01:15

Right. I haven’t seen the JAR appear either. It can take a while.

dnolen22:01:19

never longer than 30 but yeah there’s a delay

dnolen22:01:50

try the guides! I’m sure there are bugs etc.

dnolen22:01:22

also around JavaScript modules support looking for ideas on how to make it simpler - I’ve implemented the obvious fundamental helpers

dnolen22:01:37

but not against some reasonable config option sugar to make it more declarative

anmonteiro22:01:22

@dnolen 1 question I just thought about: can we consume CLJSJS modules just for externs?

anmonteiro22:01:33

I think the answer is "no" given the way they're currently packaged

dnolen22:01:51

@anmonteiro the answer is “yes"

dnolen22:01:59

we blindly collect externs

dnolen22:01:08

we don’t look for specific ones on the classpath

anmonteiro22:01:30

so we can have a CLJSJS dep in the classpath and just not require it in our code?

dnolen22:01:34

that’s how the last part of JS modules guide works

dnolen22:01:37

that’s right

anmonteiro22:01:52

awesome. OK I should go RTFM and report back. sorry for the noise

dnolen22:01:18

in fact far as I can tell we will need CLJSJS for some time

dnolen22:01:37

Closure compilation will rename internal dynamic stuff - the only way to prevent that is community maintained externs

dnolen22:01:10

in fact some externs aren’t supplied and I had to hand code those + pull in some Node.js stuff

dnolen22:01:29

but people can figure out what’s working and what’s not

anmonteiro22:01:42

did anything change at all wrt to advance compiling for :target :nodejs?

dnolen22:01:48

the good news is that it seems very practical to compile from node_modules

dnolen22:01:52

React is a non-trivial thing to build

dnolen22:01:16

@anmonteiro nothing should have changed for advanced compiling :nodejs

dnolen22:01:24

all the changes for Node.js were dev time stuff

dnolen22:01:33

loading namespaces on the fly

anmonteiro22:01:21

@dnolen just saw your es6-demo branch for React

dnolen22:01:37

that’s in the guide now

anmonteiro22:01:47

makes sense you got it to work under advanced compilation, but you'll have a much harder time getting Maria's circle project to work

dnolen22:01:33

@anmonteiro right but the circle project is harder for now obsolete reasons

dnolen22:01:47

trying to mix foreign lib with CommonJS

dnolen22:01:04

now you can just do CommonJS no old style foreign lib

anmonteiro22:01:19

you have the first part in your es6-demo project

anmonteiro22:01:31

with the others I got React to work under advanced

anmonteiro22:01:46

(both Circle + the Om Next devcards worked great with those)

dnolen22:01:02

but those should get pushed to CLJSJS

anmonteiro22:01:05

perhaps I shouldn't be lobbying this to you, but to CLJSJS 🙂

tony.kay23:01:56

Super excited about this add! Been avoiding a number of js libs that I'd like to use waiting for this!

anmonteiro23:01:59

BTW the CLJS 1.9.456 artifact is now in Maven

juhoteperi23:01:04

@anmonteiro No lobbying necessary, just make PR with a short description about what those are used by

anmonteiro23:01:29

Sure, I didn't mean it like that 🙂

anmonteiro23:01:37

just that it needed to be brought up

isak23:01:16

hm, i get runtime errors like this with the newest cljs compiler that I don't get with the previous version:

Invalid Om component fn, app$ui$views$root$render_app does not return valid instance
(or (satisfies? IRender x) (satisfies? IRenderProps x) (satisfies? IRenderState x))
Haven't been able to find a minimal repro yet.