Fork me on GitHub
#clojurescript
<
2016-09-17
>
orther01:09:49

anyone suggest a non react-native lib/tutorial to jump into tvOS dev with CLJS?

orther01:09:20

found some good looking articles on google but figured I'd asl

vjunloc02:09:20

Beginner here, are there any good tutorials for clojurescript with react ?

snoonan02:09:00

There are a few good libraries that encapsulate react in different ways

snoonan02:09:46

reagent re-frame reactive and om

snoonan02:09:02

depending on how clojure-like you want react to be (and other big things as well)

attentive05:09:34

Hi all, got a bit of a curly question, what's the best way to invoke a js method on an object by name in ClojureScript? I want to write a macro that converts a nice consistent fluent JavaScript API to a bunch of ClojureScript functions in a namespace.

attentive05:09:47

So eg (.fluent-fn handle arg1 arg2) === [magic] ===> (converted-fluent-fn handle arg1 arg2) where the only input to [magic] is the string name of fluent-fn

attentive05:09:35

To take it a little further:

attentive05:09:52

(defmacro convert
    [fn-name]
    `(defn ~(symbol fn-name) [args] (apply (something!) args)))

hueyp05:09:17

whats the benefit of not doing (.thing handle arg1 arg2) ?

attentive05:09:44

What is "something!" if fn-name is a JavaScript method of the handle (first arg in all cases)?

attentive05:09:13

Nothing really, just I've started building some more primitives on top of the core functions the JavaScript library provides, and I'd like to preserve consistency

hueyp06:09:38

so cljs seems fine with apply on methods, e.g. (apply thing.bar [1 2 3])

hueyp06:09:10

I am macro dumb but

(defmacro convert [fn-name]
  (let [x (gensym)]
    `(defn ~fn-name [~x & args#]
       (apply ~(symbol (str x "." fn-name)) args#))))
?

attentive06:09:09

Thanks, I'm going to give that a try (also macro-nooblike)

vjunloc14:09:14

How can i read documentation in figwheel repl ?

vjunloc14:09:02

doing

(doc map)
throws error
----  Compiler Warning on   <cljs form>   line:1  column:2  ----

  Use of undeclared Var cljs.user/doc

  1  (doc map)
      ^--- 

----  Compiler Warning  ----
#object[TypeError TypeError: Cannot read property 'call' of undefined]
nil

vjunloc14:09:22

Is there a beginner friendly slack channel for clojurescript ?

vjunloc14:09:59

This slack channel seems to be low on activity

vjunloc14:09:33

or may be i am spoiled by Elm's slack channel

shaun-mahood14:09:38

@vjunloc: #beginners is a good spot

plexus14:09:37

@vjunloc it gets busy here sometimes, it depends šŸ™‚

vjunloc14:09:57

no worries, i have posted my question in beginners channel

coyotespike19:09:27

I'm figuring out the Sente library. Last year figuring out basic web comms was painful, and this looks great. I have a couple of questions. First, is there any situation when you wouldn't want to use this library? Seems like it combines Ajax and WebSockets, so I can just use this for basically every client-server interaction?

coyotespike19:09:19

I'm asking because Rich Hickey says that programmers know the benefits of everything and the tradeoffs of nothing šŸ˜‰

coyotespike19:09:23

My second question is pretty specific. You can send a message in Sente: (chsk-send! [:rente/testevent {:message "Hello socket Callback!"}]. This has no CSRF token explicitly declared. I'm reading the docs and can't tell if that's because it's sending the token back under the hood, or because it's not needed.

coyotespike19:09:04

This is in contrast to this example from the docs:

(sente/ajax-lite "/login"
              {:method :post
               :headers {:X-CSRF-Token (:csrf-token @chsk-state)}
               :params  {:user-id (str user-id)}}

coyotespike19:09:36

Using the ajax-lite method, we do have to explicitly send the CSRF token, which is easily obtained from the chsk-state atom.

coyotespike19:09:51

Maybe I should ask all this on the repo?

lspector19:09:49

Inspired by @dnolen comment that "your browser is a lisp machine" and the screeshot in https://www.youtube.com/watch?v=mty0RwkPmE8 (around 24:30), I'd like to try using Chrome as a ClojureScript IDE... and so I installed the ClojureScript REPL extension in Chrome and I have a little doodad in my Chrome windows next to the address field... and it's a menu that will just take me to the Chrome web store to get the thing that I already have... But how do I make this go, to look like what @dnolen has there? Probably obvious: I'm pretty new to ClojureScript and any web/browser development

lspector19:09:38

And I miss Lisp machines šŸ˜ž

darwin19:09:00

@lspector I just watched it earlier today and to me it looked like a stock Chrome DevTools, no extensions/plugins whatsoever

lspector19:09:33

Thanks -- but how does one "make it go"?

darwin19:09:39

btw. @dnolen, thanks for the cljs-devtools plug šŸ™‚

darwin19:09:49

@lspector: you probably want to use https://github.com/binaryage/cljs-devtools, and later when you get familiar with all the tooling, check out Dirac DevTools as last step: https://github.com/binaryage/dirac

amacdougall19:09:48

Just to add the stack of questions here: does :include-macros work even when namespace bar.core contains only macros? Specifically, I'm trying out this:

(ns foo.core
  (:require
    [cool.project :as cp]
    [cool.project.macros :as cpm :include-macros true]))

amacdougall19:09:41

:require-macros works fine for this, but since it's in a cljc file, it would be cool if I could just use :include-macros true and let clj compilation ignore it.

lspector19:09:40

@darwin: Thanks -- I'll read what's at those pointers. BTW I only just now found the Chrome View > Developer > Developer Tools menu item, so I wasn't kidding when I said I was new to this.

darwin19:09:21

@lspector oh, then you should probably start here: https://developer.chrome.com/devtools

amacdougall19:09:30

@lspector: In that case, unless something about Clojure is really speaking to you, I suggest getting up to speed on using JavaScript in the dev tools first.

amacdougall19:09:06

It's entirely possible to use CLJS without touching much JavaScript, but it will be very helpful to know at least the basics.

coyotespike19:09:50

I'll second the recommendation to learn a bit of JS - I started CLJS without JS, and translating from JS to CLJS was painful. Now that I know some JS it's much easier.

coyotespike19:09:01

OTOH, I've never felt the need to know any Java.

lspector19:09:21

@amacdougall: I'm deeply committed to Clojure. Pretty new to web programming. This would be for doing Clojure/Script in a nice way in browsers (possibly an alternative to Gorilla REPL, possibly for teaching beginning programmers). I won't take time to learn JavaScript for any of these purposes.

amacdougall19:09:07

If you're experienced with Clojure, I'm sure you can figure out the web stuff without knowing JavaScript.

lspector19:09:49

Actually, "pretty new" understates it -- did a little at the very beginning of the web, then a tiny bit lately via clojurescript but only leveraging very nice tools like https://github.com/fasiha/re-simple-term

coyotespike19:09:08

for me, just knowing basic syntax so I know what's a method and what's a property and what functions to translate was helpful. But I've never done web dev in anything other than ClojureScript. Don't think I ever will.

lspector19:09:38

I find the web stuff to be a pretty steep wall because most people in the space do know JavaScript, and don't realize the depth of my ignorance šŸ™‚

amacdougall19:09:26

Well, you can't blame web developers for knowing the one language that runs in the browser!

amacdougall19:09:37

I'm just glad there are so many compile-to-JS alternatives.

lspector19:09:10

I don't blame them. But my goal here is not to do any web programming, just to have a nice environment to write Clojure/script in a browser. I absolutely love Gorilla REPL, but that screenshot and @dnolen's comment about lisp machines made me wonder if something much better was already available. Looks like maybe? But I'll have to figure out how to use it, and whether it will really serve this need.

amacdougall19:09:56

If you're doing any kind of browser-based stuff, I strongly recommend Figwheel, too. Every time you save a file, your changes will be reflected in the running app in the browser. It's magical.

lspector19:09:34

BTW one nice thing about Lisp machines was that all you had to do to make the Lisp environment "go" was to turn them on šŸ™‚

coyotespike19:09:36

Yes, Figwheel or Boot. Hot-reloading is the bomb.

amacdougall19:09:23

I think that for Figwheel, you have to be using a particular webapp framework, though, which may not be what you're looking for.

amacdougall19:09:45

You said you're not doing web programming, so on second thought, I guess Figwheel wouldn't help.

lspector19:09:16

I hear you on figwheel, which I use when doing my little thing with https://github.com/fasiha/re-simple-term. Very nice. But what I'm aiming for here wouldn't even involve a separate running app -- just a coding/debugging environment with a REPL

darwin19:09:57

then Chrome Devtools is not a good fit for this IMO, you are looking for some (bootstrapped) clojurescript REPL project, something like klipse or http://clojurescript.net

lspector19:09:02

Thanks @darwin. I did look at http://clojurescript.net and some related things earlier, which was what eventually led me to re-simple-term, which turned out to be the best way for me (with my limited web programming knowledge) to solve the problem that I had at the time (just if you're curious, because it's totally niche: http://faculty.hampshire.edu/lspector/dda). I saw some of the klipse stuff announced recently, but not that particular interface... which looks potentially great! I'll check that out more. But FWIW none of this appears immediately to offer the kind of editing/debugging environment that I was imagining from @dnolen's talk might be available in Chrome

darwin20:09:08

Do I understand you well that you are looking for a web-based coding environment, where one could develop simple clojure(script) programs, evaluate them with integrated debugger? newbie friendly, hiding complexities of underlying platform?

darwin20:09:21

Iā€™m afraid nothing like this exists

lspector20:09:27

Yes, that would be awesome. Too bad it doesn't exist! To be a little more clear, the "web-based" part is only there for me because browsers are sometimes good platforms. But I'm constantly circling between the currently available development environments looking for one with the right combination of all of the other things you mention... every half-year or so trying the latest versions/setups of all of the IDEs, editors, etc. The browser platform provided what I felt was the best option for my class last semester (Gorilla REPL with a bit of tweaking and advice: http://faculty.hampshire.edu/lspector/temp/Secrets-of-Gorilla-REPL.pdf), but it's not perfect (e.g. I don't yet have a way to save files without markup) and debugging features would be nice... So when I saw that Chrome screenshot it wasn't a big leap to think that there's maybe there's another, better option that also leverages browser technology.

amacdougall20:09:50

Have you tried Cursive? I haven't tried it myself, but I've heard that it has a good editor and debugger. Of course, then you're installing a big application, which might not be much help either.

darwin20:09:10

Cursive is a PRO tool, he wants something his students will be able to tinker with in minutes

amacdougall20:09:35

Ah, and you just said "trying the latest versions/setups of all of the IDEs, editors, etc.", so never mind. I should read more carefully!

darwin20:09:49

no debugger, obviously

darwin20:09:21

and would have to be tailored for non-reagent use cases, I guess

lspector20:09:49

I have indeed tried Cursive and I see there's a lot to like there, especially on debugging. But last I checked it out the getting started text and process included a bunch of stuff that I didn't understand myself, with decades of programming experience and a PhD in compsci šŸ˜•... so not quite right for newbies IMHO. I chatted with with Colin Fleming and he was really nice and responsive, but at least at the time I didn't think Cursive would be the choice for my audience for a while yet... but I should check again, since it looks like that was 9 months ago. FWIW Counterclockwise has often been the thing that I've found to serve these needs best, and I've used it in several classes and for research development (and the Counterclockwise developers have also been super helpful and responsive). Both with Cursive and with Counterclockwise there's lots of incidental complexity that comes with the platform (IntelliJ, Eclipse), which would be fine if it would stay out of the way of newbies, but that's the tricky part. Counterclockwise's standalone version and drag-to-open-project helped on this front a lot, but there's still a lot of confusing stuff cluttering it up, that just comes with the Eclipse territory.

lspector20:09:21

Also just FWIW, I was spoiled by Lisp machines and other early Lisp environments (especially Macintosh Common Lisp) that I thought worked well both for newbies and for pros. This is probably why @dnolen's comment got my blood racing šŸ™‚

lspector20:09:17

cljsfiddle is certainly interesting... not quite what I'm looking for here, I don't think, but I will keep it in mind

misha20:09:54

greetings! what is the "accepted" policy on including core.async as a dependency in a library (or rather tiny framework)? should I have a bunch of atoms as a library integration points, or those would better be channels? is there a universal rule/preference, or is it highly contextual?

darwin20:09:57

in general, if your library needs state, you should provide a factory to create it and a way to pass it into your api, what you put inside is highly contextual

darwin20:09:35

in other words: ideally, there should be no global state hidden in your library

misha21:09:59

ok, suppose I use provided state, but have a chain of dependencies, which can be represented as series of add-watch on atoms or as a bunch of channels. is there any preference there?

misha21:09:08

e.g. I get some input from user, and under the hood I subscribe to certain events (clicks, drags, etc. which is really would be boilerplate if required as part of setup/integration). The combination of those inputs (implicit and explicit) produce branchy chain reaction, resulting in lib usefulness and justification of its existence.