Fork me on GitHub
#clojurescript
<
2017-07-04
>
leontalbot00:07:31

Would you know what is the JavaScript object to enter for this lib?

mobileink03:07:37

when does it make sense to reimplement a js lib as a cljs lib? I'm looking at the polymer source at https://github.com/Polymer/polymer and I'm thinking it would not be all that difficult to make a pure clojurescript version. But other than advanced optimization and namespaces, I'm not sure what that would buy us.

cfleming05:07:20

Is it a true statement that for any CLJS interop form like (.method <object> <params>), method must be on an object prototype?

cfleming05:07:40

i.e. it must be like some.ns.MyObject.prototype.method = function() {etc etc}

cfleming05:07:18

I guess the other case is if you explicitly assign a function to an object instance and then call it, but it seems like that would be uncommon.

anmonteiro05:07:39

@cfleming not a true statement, nor a good assumption

anmonteiro05:07:30

under Node.js:

cljs.user=> (def path (js/require "path"))
#'cljs.user/path
cljs.user=> (.resolve path ".")
"/Users/anmonteiro/Documents/github/clojurescript"
cljs.user=>

cfleming05:07:02

How is the path object defined, though?

cfleming05:07:12

I guess that’s a module, right?

anmonteiro05:07:14

path is the exports of a module

cfleming05:07:23

How would resolve be defined in the JS code?

anmonteiro05:07:28

you can think of it as an object

anmonteiro05:07:20

something like

function resolve(){
...
}

module.exports = {
  resolve: resolve
}

cfleming05:07:34

Hmm, I see.

cfleming05:07:53

This is in the context of completion, BTW, just trying to figure out where I should be looking for candidates.

cfleming05:07:26

I’ve been planning to try to understand the JS module system better, I might have to now.

anmonteiro05:07:40

granted, this is under Node. So I don’t need to worry about anything else 🙂

cfleming05:07:58

And works by talking to the live system, correct?

cfleming05:07:08

Sadly, I can’t do that.

anmonteiro05:07:19

ah right. the SDK thing

cfleming05:07:26

Ok, thanks - I’ll check out the module system stuff.

cfleming05:07:42

More the static analysis thing.

anmonteiro05:07:46

perhaps this is not the best way to start

anmonteiro05:07:27

I guess if this is for Cursive & ClojureScript nailing down goog stuff & foreign lib would be more approachable?

cfleming05:07:45

Yes, definitely more important.

cfleming05:07:50

I think I have most of that working now.

anmonteiro05:07:54

@cfleming and for foreign libs that have externs you have a lot of work done for you

cfleming05:07:26

They tend to define functions like Object.prototype.method = function() {}

cfleming05:07:33

So all that is fairly straightforward.

anmonteiro05:07:45

exciting stuff

anmonteiro05:07:05

I’m not a Cursive user myself but I know a handful of people that will be very happy with that support 🙂

cfleming05:07:41

Actually all that works (to some degree) in Cursive now, I’m just improving the performance, and working on better test coverage.

cfleming05:07:27

At some point soon I’ll attempt type inference too, which is very helpful in Clojure. There’s less information in CLJS though, but I still expect it to be useful.

dominicm08:07:09

I notice that on a def, the :file metadata is an absolute path, unlike in clojure where it is a path relative to the classpath. Is there any reason for this?

dominicm08:07:44

http://swannodette.github.io/2014/12/17/whats-in-a-var looks like this might not always have been the case.

dominicm08:07:27

But it is the case with latest mies.

dominicm08:07:16

Using the old mies (0.6.0) which was cljs "0.0-3308" also used absolute paths

grav08:07:45

So happy to see @cfleming in this channel 🙂

cfleming08:07:32

@grav I always lurk here 🙂

grav08:07:56

Haha, well seems like you’re doing more than lurking, and that can only mean good things for Cursive’s cljs-story 🙂

cfleming08:07:13

Definitely! Lots to come 🙂

grav08:07:22

Great to hear!

myguidingstar12:07:49

@thheller I'm trying to use shadow-cljs to write a node module. It works with (cljs/once :my-id) but when using (cljs/watch :my-id)or (cljs/dev :my-id) I got this error: clojure.lang.ExceptionInfo: missing instance

thheller12:07:15

@myguidingstar oh oops, these currently assume to have the embedded server running (which the shadow-cljs CLI command launches). you can launch it manually by calling (shadow.cljs.devtools.server/start!)

thheller12:07:42

only need to start it once per JVM

myguidingstar12:07:45

it works. Thanks a lot @thheller

myguidingstar12:07:55

shadow-cljs is great

isaac13:07:43

cljs has no clojure.string/re-quote-replacement?

moxaj13:07:04

@isaac you can probably use goog.string.regExpEscape

dnolen13:07:13

does not, looks like it relied on a Java thing so it wasn’t ported

isaac13:07:47

@moxaj that really good, thanks

isaac13:07:17

@dnolen IMO, define an alias re-quote-replacement in clojure.string of cljs has better uniform with clojure

dnolen13:07:23

@isaac what do you mean?

dnolen13:07:15

(btw I’m not suggesting it shouldn’t be ported if it can be done simply, just explaining why it’s not there)

isaac13:07:52

if ported it to cljs.string, the cljc file writing more convenient

rnagpal13:07:32

I just got started on Clojurescript and trying out my first hello world. How can I add bootstrap to project created using https://github.com/reagent-project/reagent-template

dnolen13:07:55

@isaac the cljc doesn’t seem essential here

dnolen13:07:37

would also tie development of that ns to Clojure dev timeline - do not want that

dnolen13:07:17

(I might be misunderstanding what you are suggesting)

moxaj13:07:57

@dnolen I think he just wants feature parity regarding re-quote-replacement, no special stuff

dnolen13:07:47

oh right - yeah so misunderstood

isaac13:07:17

@dnolen I mean, we need not use conditional read in code like belowing, if we ported?

(defn foo [s]
  #?(:clj (str/re-quote-replacement s)
     :cljs (gstr/regExpEscape s)))

dnolen13:07:39

@isaac yes sorry I understand now

dnolen13:07:24

someone should make an issue and suggest that patch but also outline where the behavior diverges so we can provide an accurate docstring to set expecations

isaac13:07:13

I would pleasure do, 🙂

rickmoynihan16:07:50

Looks like the clojure 1.9 uri? predicate is missing from cljs

dnolen16:07:03

@rickmoynihan yeah would probably need to tie to Closure Uri type

anmonteiro20:07:17

I’ve seen people have problems with Google Analytics & advanced compilation

anmonteiro20:07:33

^ this will be in the next ClojureScript release

mikerod22:07:31

so, since searching has failed me (somehow), does anyone have a good cljs client-side approach to making a button that exports a table to csv?

mikerod22:07:55

the key part being cross-browser support (including like IE9+) where it downloads a generated file

mikerod22:07:04

The creating of the actual CSV part isn’t something that really needs much assistance. This cross-browser supported, client-side download a generated file part seems to be problematic via searches. I haven’t found anything in about it with respect to cljs or google closure though, so making sure I wasn’t missing anything out there

mikerod22:07:40

I think I’ll probably just end up doing it server-side to avoid the drama

grav22:07:14

@mikerod We ended up using the download attribute on the link, but that’s not IE compatible at all. Alternatively you can send the Content-Disposition header, but since you cannot control the header in an <a href=, you need to do an XHR request.

grav22:07:54

No wait a moment, that’s not true. The server needs to send the Content-Disposition header in the reply. That should be cross-browser as far as I know.

grav23:07:33

At some point we experimented with using XHR and embedding the download-file in a link, but I forget why 🙂 Might be because it’s a way to ensure download without having control over the server. I’m afraid I don’t have any code, nor do I have good search terms for googling it