Fork me on GitHub
#clojurescript
<
2016-12-21
>
dnolen00:12:46

@pandeiro the classpath is how dependencies are resolved including dependencies between namespaces in your own source directory

dnolen00:12:29

years ago the compiler did build only (mostly?) from a source directory but this just a huge pain since that’s not how Java resolves resources

pandeiro00:12:50

ah ok thanks; so that first example 'works' b/c there's no require maybe...

darwin00:12:16

@chrisoakman cljs-oops[1] provides aget on steroids: [1] https://github.com/binaryage/cljs-oops

kenny01:12:30

Is it possible to replace a method on a deftype?

esanmiguelc02:12:44

newbie question: is format not available in cljs ?

kenny03:12:25

Is it possible to get a function off of an object? Something like this:

(let [x {:a "a"}
      -lookup' (.-lookup x)])

thheller09:12:12

@kenny to override a method on a deftype use extend-type or extend-protocol, but that is probably not a good idea to do

thheller09:12:58

also don't try getting a function off an object, it will only lead to bad things

thheller09:12:09

ie. breaking :advanced compilation and so forth

thheller10:12:17

oh there is also specify! if you just want to alter one instance

fevral1311:12:29

@kenny if only thing you need is alias for object method, wrap it into anonymous function: (let [-lookup #(.lookup x %)])

pesterhazy11:12:36

what part doesn't work, @rb1719 ?

pesterhazy11:12:24

on-click needs to be an anon fn, not a fn call

rb171912:12:44

@pesterhazy do you mean #(swap! change (replace-value %)) because I tried that and it doesn't work either

pesterhazy13:12:18

Try starting with a known good base, they add things from there

pesterhazy13:12:37

It feels like you're doing too many things at once

bleadof13:12:45

Is there any way to debug this?

ERROR: JSC_DUPLICATE_EXTERN_INPUT. Duplicate extern input: /home/ubuntu/project/externs/google_maps_api_v3.js at (unknown source) line (unknown line) : (unknown column)

bleadof13:12:29

My build machine is running into this, but I can’t reproduce it loaclly

pesterhazy13:12:28

@rb1719 , oh and it should be :on-click #(swap! tdata replace-value)

rb171913:12:07

@pesterhazy I have tried :on-click #(swap! tdata replace-value) but when I click the button, it removes the table. Because at first the table shows YUM.N and then when you click the change button it should change YUM.N to hello. Do you have any idea why it's removing the table?

borkdude15:12:16

Is there perhaps a known issue with cli arguments in advanced output for node?

borkdude15:12:05

CLI arguments are correctly received using :none or :simple, but not :advanced. The quickstart seems to suggest using :simple should be enough for Node though.

anmonteiro15:12:55

I think you'll find lots of unexpected stuff when compiling code for Node in advanced

anmonteiro15:12:03

I don't think it was ever a goal to make it work

borkdude15:12:14

ok, so :none for dev, :simple for dist

anmonteiro15:12:45

Lumo releases for example use :simple

borkdude15:12:01

Maybe the quickstart should discourage it a little stronger then, I’m fine with this, but as a cljs+node newbie I didn’t know this

borkdude15:12:02

@anmonteiro how do you develop for node, just output a new file and run it, or do you use hot reloading for node as well?

anmonteiro15:12:33

Lumo's use case is non-trivial

anmonteiro15:12:41

I just output a new file and run it

borkdude15:12:10

I don’t know if there is such a thing as hot reloading for node, just wondering how people use it

anmonteiro15:12:26

I think there is, and that Figwheel supports it?

timgilbert15:12:05

Can anyone give me general advice on integrating with a native JS library written in ES6 and ordinarily integrated into other JS stuff via npm and webpack? I'm a bit baffled on what the cljs equivalent of import { StyleSheetServer } from 'aphrodite'; is

thheller15:12:10

@timgilbert my advice would be to package all of the external dependencies together using normal JS tools (ie. webpack)

thheller15:12:37

and then either include this in your build as a :foreign-libs or leave it out completely and just add some externs for it

thheller15:12:09

that is for the browser

thheller15:12:18

if you just want node

thheller15:12:10

(def StyleSheetServer (.-StyleSheetServer (js/require "aphrodite")))

timgilbert16:12:26

I'm targeting the browser, yeah

borkdude16:12:01

Are there any cool cljs libraries focusing on node I should check out?

agile_geek16:12:52

@borkdude I've been playing with using node for isomorphic rendering and I followed that link about figwheel and it seems to work for me although I'm having to customise it a bit and a few things broke

borkdude16:12:09

I’ve been wondering about the preference for async in JS. In a browser I could imagine that this is done to keep things responsive. But why is the fs api in node async for example

samcf16:12:24

afaik because the thinking is that most of the request is spent doing IO

thheller16:12:49

@borkdude node is async because it only has a single thread, if you were to wait for IO you could basically only ever process one request at a time

thheller16:12:11

which would make for a very bad server

borkdude16:12:48

that makes sense

thheller16:12:07

node.js still makes for a very terrible server though, even with async IO 😉

Aron16:12:40

what do you mean, terrible server? compared with what? php cgi?

thheller16:12:39

compared to the better option: clojure 🙂

mccraigmccraig16:12:17

@borkdude some of us have a preference for async everywhere - all my backend clojure is async

stbgz18:12:26

@borkdude fighweel does support node js hotreloading, as long as you set up your cljs project with it

stbgz18:12:54

it’s actually a pretty cool way to develop

bbloom18:12:55

what’s the preferred client-side date/time library these days?

borkdude18:12:38

@bbloom I see cljs-time often used

bbloom19:12:04

ok - was looking at that

bbloom19:12:27

i only ask b/c i’ve suffered many a bad date/time library in my career and they are kinda hard to evaluate b/c the api surface area is always so large

bbloom19:12:51

yeah, i’ve foudn moment to be pretty good - was considering just using it directly via js interop

chrisoakman19:12:19

That would be my approach as well.

bbloom19:12:18

i think that’s what i’m gonna do - if for no other reason than i already know the api, thanks both of you

bleadof19:12:04

I made a cljc wrapper for clj-time and moment js, but I can’t open source the code yet. 🙂

bhauman19:12:33

@bbloom just going straight goog.closure is probably a really good choice

bbloom19:12:43

@bhauman uugh mutable date objects

bhauman19:12:12

actually it's pretty sophisticated

danielcompton19:12:25

@bbloom cljs-time mimics clj-time's API

danielcompton19:12:32

so if you're happy with one ...

bbloom19:12:53

in clj land i’ve mostly used joda time directly

bhauman19:12:09

I normally find the 4 operations I need and write up a tiny wrapper around goog.closure stuff

bbloom19:12:58

i’ve managed to accomplish what i needed via moment super quick

bhauman19:12:15

btw I'm hot reloading es6 jsx code in figwheel right now

bbloom19:12:19

it’s stuff like setTime, setUTCMonth, etc on the goog interfaces that i dont’ want anywhere near my code

bbloom19:12:29

mutable dates are the worst idea in the history of computing

timgilbert19:12:33

I have to say I'm not crazy about cljs-time's API, you wind up needing to import a lot of namespaces to do simple stuff

bbloom19:12:38

doesn’t matter how nice the library’s not mutative interface is 🙂

danielcompton19:12:47

worse than null?

bbloom19:12:12

clj-time and cljs-time seem to have a lot of vars that you need to access

bhauman19:12:43

I think it's high time you wrote the perfect datetime library for cljs

bbloom19:12:53

moment.js’ interface is nice b/c it relies on context and dynamism for things that are contextual and dynamic - ie rather than try to enumerate all the parts of a date/time as individual vars, you can just compose some strings to specify what you want

bbloom19:12:59

a good clj date/time lib should use keywords similarly

bhauman19:12:05

an old programmers curse

bbloom19:12:32

i want nothing to do with owning a datetime lib - holy hell, that sounds like a nightmare

bbloom19:12:34

time sucks. 🙂

bhauman19:12:51

the time should be the same everywhere

bhauman19:12:03

that would fix only part of the problem

noisesmith19:12:24

or we could just stop time forever, it would simplify a lot of things /supervillian

bbloom19:12:28

time zones ಠ_ಠ

bhauman19:12:41

time zones daylight savings

bbloom19:12:03

leap seconds (┛◉Д◉)┛彡┻━┻

bhauman19:12:05

I'm surprised we even know what time it is

bhauman19:12:50

Time for me to do the last nights Advent of Code problem. I like doing these problems too much.

bhauman19:12:30

finite programming challenges that allow me to explore Clojure further

bbloom19:12:15

i’ve got a function i’ve been putting off writing all morning, if you want another finite coding challenge 🙂

bbloom19:12:57

i need partition-by where the partitioning comparison is relative, not equality - ie partition whenever there is a gap in time

noisesmith19:12:43

so like bucket-by

bbloom19:12:00

is that a thing somewhere?

noisesmith19:12:11

no, just attempting to coin a name

noisesmith19:12:31

seems like (partrition-by #(< delta (- (second %) (first %))) (partition 2 1 coll)) gets you 1/4 of the way there?

bbloom19:12:35

i was thinking more like partition-when plus a separate pass to compute the delta. so then (partition-when #(> (:delta %) threshold) ...

bbloom19:12:34

oh man, it’s been too long since i’ve done 4closure - i forgot about overlapping partitions!

noisesmith19:12:03

throw in (map (juxt comput-delta identity)) for extra fun-times

noisesmith19:12:16

(and mutatis mutandis on the rest, of course)

bbloom20:12:11

@noisesmith this doesn’t quite work b/c if you have two gaps in a row, then you won’t get partitioning b/c you’ll have true = true

noisesmith20:12:05

ahh! - so you need a reduce I think

bbloom20:12:15

nah, i’m just going to use lazy-seq

dnolen20:12:52

@bhauman: sweet! So changes worked for you? Still thinking about how to handle es6 sources

bhauman20:12:11

yeah the changes just worked

bhauman20:12:20

so the example still works

bhauman20:12:03

The es6 dir solution seems the most straight forward but looking forward to your thoughts on this

dnolen20:12:41

Yeah tying to one thing seems undesirable

dnolen20:12:05

But nothing stopping foreign lib entry just listing a directory not a file

dnolen20:12:45

And you can supply module format and preprocess as usual

bhauman20:12:19

yeah that was what I was getting at, no tying to a certain module or preprocess

bhauman20:12:00

seems straight forward as it just expands to the individual entries