This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-01
Channels
Suppose you have a lot of namespaces, but want to have a single names space that refers to a few vars in those others. The idea is that users can just simple.ns/this and simple.ns/that rather than have to care about all those implementation namespaces.
@zentrope: This may be relevant: http://side-effects-bang.blogspot.com/2015/06/importing-vars-in-clojurescript.html
I bet it’s not working because I’m using defcomponent (quiescent) which is probably not creating the var I think I’m creating. Or something like that.
There’s also that (repeatedly (identity #’something.or/other))
I’ve seen somewhere … can’t remember what it was.
@zentrope: One note: With the way you have MyThing
defined, it is bound to the var, so you’d need to use @MyThing
to get to the value of other.ns/foo
.
Is there a reason (partial ...)
and #(some-fun ...)
are not executed in ->
and ->
?
Example: (-> "World" (partial println "Hello"))
I keep on writing things like (-> "World" ((partial println "Hello")))
and (-> "World" (#(println "Hello" %)))
. Either my approach is bad/wrong or I'm missing something. (-> "World" println)
works and my thinking is that println
is no more or less a function than (partial println "Hello")
or #(println "Hello" %)
should be.
Ah. Because -> is a macro, (partial println “hello”)
is not evaluated before the macro rewrites it as (partial “world” println “hello”)
.
@jannis: I was initially confused by ->
in what I suspect is also confusing to you. It is not passing values to subsequent functions for execution. It is much simpler and just rearranging the code.
It turns forms into lists if they aren't and then basically inserts one form into the next to build the final expression.
Yeah. Ok, I get it. And it does fun stuff with anonymous functions, like (fn* "World" [] (println "Hello"))
😄
@zentrope: @mfikes: Thanks for the explanation. I've been using Clojure/CLJS for a while now but haven't thought much about how it does things like this.
this style on ns :requires seems pretty neat https://github.com/danielsz/system-advanced-example/blob/master/src/example/systems.clj#L4 but it seems clojurescript doesn't this ?
@nowprovision: correct, that is not supported
@nowprovision: FWIW, prefix lists are mentioned at https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces
I'm curious if anyone has already written an example of connecting an Om Next app with a boring REST API. Part of the motivation of Om Next is that REST is bad—but REST is mad entrenched. I think understand how to go about it, but if someone else has already written it, why reinvent the wheel? (...weird to think of REST as "legacy" in a world that still has SOAP APIs. I guess everything is contextual.)
is there any tool which would show me where exactly I have a circular dependency? I did pretty large refactoring and now getting StackOverflow errors from analyzer. I know it is a circular dependency but I’m sick of trying to comment out individual requires to pinpoint the problem.
@darwin: if there is, I'd like to know it
I've been in the same situation
it took me 30 minutes to figure out, that I was requiring my own namespace, (:require-macros [my.ns :refer …]) was fine, but I replaced it with (:require [my.ns :refer-macros …]) - it makes sense, but it was hard to find this needle in this change set: https://github.com/darwin/plastic/commit/c27151a0ed07b4faade721dc53f5241156cb6b7c
better error messages would help here
@thheller: I’m still looking for good layout, the problem was that part of my sources should go into a web worker, part into main js context, part is shared, and meld is going to be a separate library one day, dev is included only in dev builds, so I wanted/needed to keep them separated because of how cljsbuild works
trying to write docs .. but looking for good examples that aren't my closed source projects from work 😛
if you are interested I'd create a fork with a shadow-build config and you can decide whether you want to use it or not
I'm not yet clear on devcards though, it seems to require figwheel which I do not quite understand why
hmm, I’m a bit afraid I would run into other problems with figwheel and maybe other tools, you know leiningen + cljsbuild path is pretty popular and bhauman has been very helpful in resolving any issues
it is not just about live-reloading, also his “HUD” system displaying errors/warnings, ability to watch multiple cljsbuild targets, etc.
and I can live with this directory layout, it is not that bad, it just forced me to do it this way, but it works
worse is, that is forced me to rewrite some libraries 😉 first I ditched servant, then rewrote re-frame and now thinking about writing my own reagent 😉
I have some support for web-workers and shadow-build that makes packaging them quite easy, even with code sharing between the main process and worker
I’m not sure if web-workers knowledge should be part build tooling, the tooling should be just flexible enough to define some hooks for including raw javascript / foreign libs
well ... it might not be in your case since you are packaging an "app" and filesize doesn't matter too much
in my case setup for dev build and final optimized build will be quite different, I assume I will rely on google closure modules for splitting
so the user doesn't download the 100kb cljs.core once for the browser and then once for each worker
yes definitely .. workers usually share a lot of code with the normal browser window
yeah, in that case modules are also a win, all shared code goes into one js file which gets cached
@mfikes: first time trying out CLJS + RN, wondering how to perform debugging
(or anyone else in the channel )
@anmonteiro: Perhaps this project leads to an ability to debug: https://github.com/decker405/figwheel-react-native/blob/master/readme.md
Otherwise it is an open issue listed on http://cljsrn.org/roadmap.html
I see
I'm also very new to XCode; is there a way to see where React Native spits out JS errors?
or this would only happen if debugging was possible?
I haven't been getting that
it just doesn't progress to my CLJS code whenever there's an error
someone here aware of a cljs.test "env" that visualizes the output in the browser instead of just the console?
something like https://google.github.io/closure-library/source/closure/goog/ui/textarea_test.html
@anmonteiro: are you not seeing anything in the Xcode "debug output" window?
nope, just the target output shows
do you mean the xcode console?
i can log from my code and see it show there
but not react's errors
not sure then
Hi. This is regarding cljsjs - If I depend on a library that provides CSS alongside the JS, do I need to download the CSS by other means and include in my HTML?
I see that the JAR has the CSS though - but I can’t find any instructions on how I can use that
@jaju: You can use ring resource middleware or compojure resources route to serve the files
@juhoteperi: I’m in an electron-shell environment. It’s a standalone app.
I have no idea how electron works but you can access the files with
But that may be useful information for me in some other context - I will keep that in mind when I need to serve from a web server. Thanks. Any docs which talk about configuring for serving?
There’s no java in electron. Plain JS (nodejs). No web-server. I need to be able to include the CSS in an HTML file read from the filesystem.
I don't think there are docs about serving the files. Some example projects probably have examples.
You probably need to use your build tool to copy files from classpath to filesystem or something.
Kind of last resort. I could use bower to get those files - easier than getting leiningen to copy maybe? But that would mean dependencies in two places, which doesn’t feel clean...
You could write a short Clojure file which copies files from classpath to filesystem and run it with lein trampoline run -m clojure.main scripts/copy.clj
Thanks @juhoteperi. I’ll keep that as an option. But I think there must be something about the cljsjs packaging that’s not known to me yet, which makes this more straightforward than this. If I don’t find that in - say - a day, copying via a script as you mention or a bower dependency is what I will need to resort to.
you would need to write some helper functions to get at their contents, index them etc. - I wouldn’t be surprised if someone hasn’t already done something like this for Node.js
is anyone aware if there's already a CLJS issue related to this "Use of undeclared Var warning.core/clj-nil" warning? (see also: https://github.com/r0man/sablono/issues/33)
I spent some time looking into this (since I'm hitting this warning in another codebase) and I think there's something up; I started trying to characterize it here: https://github.com/sumbach/type-leak-test/tree/unit-tests