This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-22
Channels
- # aatree (21)
- # announcements (10)
- # avi (1)
- # aws (15)
- # beginners (96)
- # boot (269)
- # braid-chat (92)
- # cider (9)
- # clara (10)
- # cljs-dev (3)
- # cljsjs (14)
- # cljsrn (20)
- # clojure (198)
- # clojure-art (3)
- # clojure-hamburg (2)
- # clojure-ireland (4)
- # clojure-russia (117)
- # clojure-spain (3)
- # clojured (1)
- # clojurescript (253)
- # code-reviews (6)
- # community-development (7)
- # conf-proposals (52)
- # core-async (4)
- # cursive (4)
- # datomic (4)
- # devcards (1)
- # emacs (59)
- # euroclojure (5)
- # funcool (1)
- # hoplon (39)
- # human (1)
- # jobs (4)
- # ldnclj (15)
- # ldnproclodo (1)
- # leiningen (3)
- # mount (37)
- # off-topic (14)
- # om (77)
- # perun (10)
- # proton (12)
- # rdf (1)
- # re-frame (9)
- # reagent (42)
- # ring-swagger (10)
- # yada (50)
anyone have any idea how to get this piece of code to compile under advanced compilation?
it did not figure out, but simply you told him not to purge the destroy
method during compilation
the rest is JavaScript and dynamically typed languages magic 😄
I’ve never seen this before: A case (in bootstrapped ClojureScript) where I wanted a function value to evaluate to itself if passed to cljs.js/eval
. I wonder if you can even do this... https://gist.github.com/mfikes/3433645e09bca86268a5
@mfikes: it’s possible to do that in Clojure, probably needs some thought wrt. what exactly we should support in bootstrapped
@dnolen: By the way, the above is just for fun. But it would indeed be cool if it can be pulled off
looks like there’s no ns-resolve
in clojurescript 😕 I can hack it with (aget js/my.name.space (munge varname))
but is there a better way?
also bootstrap -> https://github.com/ScalaConsultants/replumb/blob/master/src/cljs/replumb/ast.cljs#L39
@dnolen FWIW, I’m solving my function value problem by instead putting numbers into the emitted JavaScript that are then looked up. It works for lambdas, etc.: https://github.com/mfikes/planck/blob/7005b6b3ffa90fb92823e1ccc14059b3acedabc0/planck-cljs/src/planck/repl.cljs#L935-L965
@jaredly: It is here: https://github.com/mfikes/planck/blob/master/planck-cljs/src/planck/core.cljs#L176-L180
cljs.user=> (ns foo.core)
nil
foo.core=> (def x 3)
#'foo.core/x
foo.core=> (ns bar.core)
nil
bar.core=> (require '[planck.core :refer [ns-resolve]])
nil
bar.core=> (ns-resolve 'foo.core 'x)
#'foo.core/x
bar.core=> @(ns-resolve 'foo.core 'x)
3
(reduce (fnil aget (js-obj)) js/window (conj (vec (map munge (.split (str the-ns) “.”))) (str the-sym)))
works great
I saw someone post a video a while ago with web & iOS & tvOS all running at same time and coding it from a repl. Does anyone know if that is still online and where I can find it?
@grounded_sage: You are probably recalling https://github.com/artemyarulin/ktoa
The only tvOS thing I’m aware of is https://youtu.be/eaWy5mliO38
Cheers. First one was the eons I was seeking
@meow: (.length my-fn)
returns the arity of a function (it’s a javascript interop thing)
seems a bit hacky, but I haven't run into the need for that so it might be what you need to do
@meow: yeah, agreed. it’s an attempt of uniting two interfaces into one, in order to make everybody happy 😉
This blog (http://blog.fikesfarm.com/posts/2016-01-20-self-calls-type-hints-and-memoization.html) says that in clojurescript, the type hint for a return value needs to be before the function definition. Is that a bug? I thought type hints for return values always go before the parameter list(s).
hi guys, I have a weird problem that whenever I include a namespace, the app just doesn't work ( the namespace and its function works fine in another namespace ) . The app ( main function ) shows blank page
@dnolen: since 1.8 type hinting before the argvec is the only reliable way to type hint return values in clojure
I'm a little bit confused with the blog post that @puzzler references, https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core.cljs#L401
@dnolen See http://clojure.org/reference/java_interop. It says return values are type hinted before arguments vector. (This allows different type hints for functions that can take different numbers of args). In 1.8, I believe Clojure can throw an error if you put the type hint before the function name (this is also referenced in the blog post I referred to). So right now, Clojurescript behaves quite differently from Clojure, it appears.
@dnolen: it doesn't print out any error message. Just blank page, there is nothing special in that namespace. I'm aware of cycle deps, can it be the cause ?
@puzzler all I know is how it worked before and that’s there a lot of code that is the old way
@puzzler take it up with @alexmiller
and I don’t really consider the clojure website to be definitive about stuff like this
In clj type hinting on the function name only works if the type hint is a non primitive type
So is it correct to say that Clojurescript currently does not support different type hints on return values for functions with multiple arities?
Sorry, I haven't tried this myself, but according to that blog post, type hinting a return value as boolean can change the outputted Javascript code to something more efficient.
Then, you says that clojurescript does not need at all the type hints, so why the cljs.core is full of typehints?
if you’re referring to the other type hints (i.e. not boolean
), I would not assume anything about that stuff
So if I understand well, it is likelly that a patch for change the typehint order is welcome (for make it consistent with clojure...)? I'm wrong?
figwheel is not re-drawing my page, and I’m not sure why. Is there any general advice to check? I’ve seen figwheel redraw successfully on this project, and I get the CLJ logo on-screen when I save files,
@arohner: Do you have something like :figwheel {:on-jsload “ns.do-something-on-reload”}
in your project.clj?
:figwheel {:http-server-root "public"
:port 3449
:repl false
:nrepl-port 7888
:css-dirs ["resources/public/css”]}
is there a way how to name anonymous function for debugging purposes? I mean achieving emitting of "named function expression” http://stackoverflow.com/questions/3854141/naming-an-anonymous-function
is it possible to see the CLJS compiler environment under &env
in macros?
If so, under what key should it be?
Possibly dumb question, but, what's the best way to check if js/some_var
is defined, or not?
(exists? js/some_var)
@darwin: like you want the cljs compiler to automatically add names to #()
fns? or do you want to do (with-name “somename” #(…))
@dnolen: was just going to write that I just found it under cljs.env
thx though
@anmonteiro: ah, k cool
@dnolen: I'm looking in the right place, right? cljs.env/*compiler*
. I can use that, ye?
@darwin: if you control the output on the other end, you can just add a custom attribute to the fn, e.g. (aset thefn “my-debugging-name” thename)
@anmonteiro: if you’re going to examine the compiler environment directly you should be OK with that not working at some point in the future
otherwise you should use one of the helper macros in cljs.analyzer.api
if something is missing
@bronsa: @spinningarrow Thanks, wonder why that wasn't on http://cljs.info/cheatsheet/
@dnolen: this is in regards to Om invariant support. Maybe we should talk in #C06DT2YSY? Just asked here because it was a CLJS general question
@darwin: or with-name
could just wrap the anon fn in a new, named fn (if that suits your needs - e.g. for tracebacks)
ok, I don't know enough about how the JS global namespace works to understand why that would be a problem
hmm I wonder how many of those functions would be on the global scope, though? seems like most of them would be in some closure or other
right — yeah that’s not what I meant. I meant a fn that’s actually defined inside of another function. (defn something[] … #(this-is-in-a-closure))
ah right for the cases where you are inside another fn yes - that's another possible compiler enhancement instead of doing it blindly
that may even be halfway done - I can’t remember if I just lost interest in it since the top level thing was more useful for debugging, perf profiling
I’m going to write jira CLJS for this minor printing patch: https://github.com/darwin/clojurescript/commit/a69374dc27434b93a4f43725643262eefecf65e5
error: Writing clj_test\suite.cljs... Writing output.cljs.edn... Compiling ClojureScript... WARNING: Replacing ClojureScript compiler option :main with automatically set value. ò output.js Running cljs tests... ERROR: doo was not loaded from the compiled script. Make sure you start your tests using doo-tests or doo-all-tests and that you include that file in your build
@laforge49: it’s a boot-centric question - but yeah maybe some Windows people here know about it
Probably boot-cljs-test specific problem
@laforge49: it may be worth your time to examine boot-cljs-test to look for any obvious error around file paths
@laforge49: in ClojureScript anyway we just went and replaced hard coded “/“
with File/separator
hi, did anybody try that tutorial: https://github.com/omcljs/om/wiki/Remote-Synchronization-Tutorial #C0DT1AZD3
@zavalit: Yeah, I just got it working yesterday
Requires a bit of finessing to get it running.
@seantempesta: can you share it maybe per gist
Yeah. I had the same problem. You’ll need to do two things. In search-field change :onKeyUp to :onChange
And you’ll need to upgrade to the latest alpha of om-next.
@seantempesta: cool, i got the input working, and now it throws "Uncaught TypeError: Cannot read property 'call' of undefined"
Yeah, that’s why you need to upgrade to the latest alpha. I think it’s 29?
[org.omcljs/om "1.0.0-alpha29-SNAPSHOT"]
Ah, just found the StackOverflow article I found these answers from: http://stackoverflow.com/questions/34603660/om-next-remote-sync-tutorial-send-to-chan
@seantempesta: thx a lot, you save me a bunch of brainfucking
Anyone here using om-next with react-native? I’ve found a lein template and a natal template so far. Any tips on which one is better or if there is another better approach? https://github.com/artemyarulin/om-next-cross-platform-template https://github.com/dmotz/natal
@seantempesta: There is a #C0E1SN0NM channel with users interested in those subjects
ah, perfect. Thanks @mfikes
Mine is better! 😄
@seantempesta: sorry for bothering you, it’s still throws smth. wiered, in my case, i get after upgrading to org.omcljs/om "1.0.0-alpha29" an error: *Uncaught TypeError: uri.call is not a function with pointing to uri out of *(defn jsonp ([uri] (println uri) (jsonp (chan) (uri)))... any idea why it can be that way?
Lein clean and rm the contents of the js folder?
And you updated the I'm dependency in your project file?
Not sure. It’s working for me.
You’re importing Jsonp? (ns om-tutorial.core (:require-macros [cljs.core.async.macros :refer [go]]) (:require [goog.dom :as gdom] [cljs.core.async :as async :refer [<! >! put! chan]] [clojure.string :as string] [om.next :as om :refer-macros [defui]] [om.dom :as dom]) (:import [goog Uri] [http://goog.net Jsonp]))
Yeah, not sure what’s going on. I just made those two changes and it started working for me.
@seantempesta @futuro thx guys, now i can finally grab some friday beer 👍
Awesome. Have one for me.
so, I’m sure this question has been asked a bazillion times, but: is there a good way to stub out js/document (and I guess maybe other stuff, this is just the current wall I’m running up against) in the CLJS nashorn repl?
I tried doing this before, and I can get this working with a test runner easily, but can’t figure out how to do testing in the repl
Is there a reason you’re not using something like Figwheel to get a browser REPL you can develop with?
don’t want to?
more specifically, trying to do the simplest thing I can first
okay. I don’t think that’s a great answer; if you want to have access to a browser environment where things like js/document will just work, a bREPL is the tool you should be using
A REPL is not a substitute for tests, surely? Regression?
…I’m trying to run tests in the repl, if that’s not clear
to get a quick feedback loop going
it’s breaking down as soon as I require anything in my ns
which refers to something in the DOM
the tests don’t even get loaded/run
so sorry—not even a question about tests, apologies for the confusion
@ddellacosta: it is an uphill battle to test DOM stuff in nashorn
simply loading up namespaces
bensu, yeah, so far that’s what it seems like. 😕
really would love to have something that is very minimal to stub stuff out, but I’m starting to think I’ll have to write that myself
@ddellacosta: I would try to use node's repl and then find an npm package that has some dom stubs
or, I would just use a browser as venantius suggested and then run the tests on Slimer/Phantom
yeah, I mean, that’s basically what I do now
just would really like to have the same quick feedback loop I do with Clojure tests
anyways, thanks @bensu, sounds like that’s the state-of-the-art right now
will check out node’s repl
I’m not sure why you’d go out of your way to use a tool that isn’t intended for browser / DOM interaction
using the Node runtime for this feels like trying to fit a square peg to a round hole
I suppose the answer is that I’ve got too much coupling in my code, and want to separate out DOM-specific stuff from non-DOM-specific stuff
but I need an interim solution before I strip everything out
in any case, ideally I don’t really do much DOM testing anyways other than at the edges, but it’ll take some time to get there, and I just want something now that lets me stub stuff out so I can at least load namespaces up without getting errors
ah well
@ddellacosta: you’re on your own if you haven’t separated DOM bits from non-DOM bits
this is the reason Google Closure Library is so useful - it doesn’t make any assumptions
yes, I understand that, thanks for reminding me that my system is not perfect dnolen
@ddellacosta: everyone can use reminding about this particular pitfall - it’s really too painful to be stuck on the other side of it
@comamitc: yes this is the place to report perceived issues, and we’ll see if it’s actually a problem
I am just getting my head around core/async. is the pattern to call your go routine in a function and update the DOM or pass the channel down to another function?
@firstclassfunc: there’s not really an established pattern around core.async and the DOM
most people are using some React binding abstraction, not core.async to deal with the DOM
@dnolen thanks yes, sorry i am using a react component updated by a cljs-http call to Datomic
@firstclassfunc: I’m not aware of any specific patterns for React in general in this case - it also depends on what binding you’re using - they have different community idioms
@dnolen: got it; thanks! I think I got past my issue so now I know for future reference 👍
@dnolen I simply want to return a collection from a cljs-http call so I can render it in OM.. But of course the return is a Go channel not my collection
@firstclassfunc: sounds like you need pass some kind of callback
@dnolen: Yea that makes sense, I just have to figure out how that will work with devcards.. Tks
are there any secrets or gotchas for converting d3 javascript to ClojureScript? I’m trying to convert this example: http://bl.ocks.org/mbostock/3885304#index.html and everything seems to work except for the:
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
line. A straight conversion to:
(.. svg
(append "g")
(attr "class" "x axis")
(attr "transform" (str "translate( 0," height ")"))
(call x-axis))
results in a Uncaught TypeError: Cannot read property 'insertBefore' of null
but taking out just the (call x-axis)
works (but there’s not axis, obviously. Grrr.Here’s a gist of all the code. https://gist.github.com/actsasgeek/3120ac9cdae44c5264b0 It’s very perplexing. If I remove both of the expressions that add the x-axis and y-axis, I get bars. If I remove (call x-axis)
and (call y-axis)
I get the <g>
elements so it seems to be the call
calls that are messing something up. I checked the values of x-axis and y-axis in the console and they are apparently identical to what the JS returns.
@actsasgeek: there’s a typo in what you pasted, early closed paren
yeah, let me fix that…it’s corrected in the gist.
@actsasgeek: otherwise seems fine
Chrom DevTools can save you a lot of time here, just set a breakpoint and see what’s going on
ok, thanks. I’ll have to give them a try.