This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-04
Channels
- # architecture (20)
- # aws (8)
- # beginners (13)
- # boot (9)
- # cider (80)
- # cljs-dev (69)
- # cljsrn (7)
- # clojure (243)
- # clojure-dusseldorf (8)
- # clojure-italy (5)
- # clojure-norway (3)
- # clojure-poland (57)
- # clojure-russia (10)
- # clojure-shanghai (2)
- # clojure-spec (11)
- # clojure-uk (50)
- # clojurescript (198)
- # core-async (11)
- # crypto (2)
- # cursive (14)
- # datomic (17)
- # figwheel (8)
- # garden (7)
- # hoplon (8)
- # incanter (4)
- # jobs (1)
- # leiningen (1)
- # liberator (38)
- # lumo (28)
- # om (55)
- # onyx (10)
- # pedestal (13)
- # perun (20)
- # re-frame (1)
- # reagent (16)
- # ring-swagger (9)
- # spacemacs (11)
- # test-check (9)
- # unrepl (43)
- # untangled (163)
- # yada (8)
I need help Why my while in scss don't work ?
$types: 1
$margin: 40px
@while $types < 5
.block#{$types}
margin-left: $margin + 20
$types: $types + 1
I need loop to create . Please help
.block1 {
margin-left: 40px
}.block2 {
margin-left: 60px
}.block3 {
margin-left: 80px
}.block4 {
margin-left: 100px
}.block5 {
margin-left: 120px
}
How to load a namespace in ClojureScript? I have a String (def s "my.name.core")
. Now I want to load this namespace. In Clojure (require s)
works. But in ClojureScript I get an error: Arguments to require must be quoted. Offending spec
. Any suggestions?
What do you mean by goog.require
? Could you please point me API docs or something? Thank you.
@darwin in a way yes .. but it is very different from require
and cannot be done dynamically in optimized builds. it works only in :none
I have a multimethod which dispatches on a keyword. And I have a lot of keywords. Now, the defmethods are all in different namespaces. But the namespaces can be derived from the keyword. Therefor I need to load all these namespaces.
So I need some hook into the build process which would produce the required code, right?
I will create a edn file with all my keywords and then write a code generator which generates a cljs which contains the requires and defines all my keys. That should work. Ugly...
@anmonteiro still tracking that async bug, i see that hasn’t released yet — is there a good place to track where they plan releases?
@witek It's not a great idea but you can write a macro that emits the goog/require
calls instead of generating cljs code
has anyone been able to use cljs.spec
in any useful manner? When I try to use it for a simple test with stest/check
I get
[{:spec #object[cljs.spec.t_cljs$spec11762], :clojure.test.check/ret {:result #object[Error Error: Unable to construct gen at: [] for: [object Object]]}, :sym graphiti-trigger.core/generate-job-name, :failure #object[Error Error: Unable to construct gen at: [] for: [object Object]]}]
backI guess it has something to do with this issue http://dev.clojure.org/jira/browse/CLJS-1792
Hi, if I have compojure/hiccup site and I would like to use after login the user data (friend/monger) at the reagent side like az “app” div integration, how to possible to do? I can put reagent application in the div etc.. but how to get data from clj side? Is that possible? (sorry for the beginner question)
I create a partial with (def foo (partial bar @bla))
but @bla
is set later. When I call the partial, the passed argument is null. How could I assure that the set atom is used?
@danielgrosse make bla dereference it
@danielgrosse try (def foo (fn [& args] (apply bar @bla args)))
@moxaj no, i wanted to shorten a function call for convinience
Hello!
I'm new here
Could someone help me? http://stackoverflow.com/questions/43208998/libs-c-blocks-editor-app-js-dependencies-google-blockly-core-blocks-js-i
For some reason out-name
is not a relative path here: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1638
rel-output-path
has own logic for Closure libs: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1545
lib-path
here https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1525 is the ""app/js/dependencies/google-blockly"
so else branch in both if
is used
I tested this with figwheel-template project + (:require [Blockly.Blocks])
+ :libs ["blockly-master"]
and this works for me
It is possible there is a bug with path handling in Windows
@mrdalloca Doesn't the exception contain stacktrace with file names and line numbers?
I'll update
Updated
is it a problem to set the cljs compiler :language-in
option to :ecmascript5
? (to use .catch
without the Keywords and reserved words
warning)
Not at all. I've just tried that and the exception remains. Thanks for the reply!
(cross-posting from #beginners; no response there) What is a simple lein template for a CLJS library project? Details: I have widgets and utility code that I've built on top of re-com for various projects. I'd like to centralize them for reuse. So, I want to move them into their own project. - This project will never run standalone, so I don't need any server component - I want a simple project.clj script that doesn't try to do too much (at least not yet!). I looked at re-com's project.clj but, at 172 lines, it is doing far more than I want to bite off right now. - This code is still evolving, so I'd like to be able to edit it live. Typically, I'll be working on it from within the context of a project using it. So, I don't think this library needs to run figwheel, right? It's code just needs to be visible to the figwheel magic in the client project. - I do want to be able to run standalone tests on this library code, without involving any client project.
@robert-stuttaford I've been tracking that too. I thought they would have released something by now
I don't know any other place than the GH repo + mailing list
I'm following both
ok, i guess i’ll go back to Strategy Alpha: Wait A While ™
thanks @anmonteiro !
@robert-stuttaford tbh I'm glad they haven't released yet, I'm hoping this makes it in https://github.com/google/closure-compiler/pull/2343
how does it help us Cljsers?
There's an issue with modules which affects us https://github.com/google/closure-compiler/issues/2377
I'm trying to track down a fix. So this fix http://dev.clojure.org/jira/browse/CLJS-1931 led to this bug https://github.com/google/closure-compiler/issues/2336 which I believe is fixed in clojurescript 1.9.495
. I upgraded clojure
, clojurescript
, and lein-cljsbuild
to the latest. However when I build, I'm still getting the same error from before the fix -- No newline allowed before '=>'
. I don't know how to move beyond this point. Any help would be appreciated.
@fearphage that bug exists in the latest cljs release
@fearphage I just reverted the cljs dependency to the version I used before, after I updated al to latest, and ran into this error..
@fearphage your conclusion is wrong. This is the ticket that led to the bug: http://dev.clojure.org/jira/browse/CLJS-1952
It’s not fixed in 1.9.494 (1.9.495 is not an official release, btw, and you shouldn’t be using it)
we’re waiting on the Google Closure Compiler team to bump the version
then we upgrade in CLJS and release a new version
Is there a path forward now with the cljs fix and some version of the compiler or am I just stuck waiting for the compiler team?
I don’t understand what you mean by “with the cljs fix"
this is Closure Compiler problem, and until it’s fixed upstream you need to use CLJS 1.9.473 or below
Well I want this cljs fix https://github.com/clojure/clojurescript/commit/af2ca808fcc5efc088b48957b898fed0b59eddbe
Maybe I'm confused. I thought I would be able to get that fix somehow without the async
bug. I don't believe that is the case.
@fearphage you need to wait for a ClojureScript release that has a dependency on a Closure release that has fixed the bug
@fearphage AFAICT you can use that fix with 1.9.473
cool!
so is that still using the technique of getting the string of a function and sending it as text?
@noisesmith I'm going to see how far I can get without using self-hosted
oh, cool - I think that's a good choice actually
Yeah, I figured out how to .call cljs compiled to js with parameters, so as long as the worker is using the same cljsbuild compilation, their names should match up.
Which is a trick servant uses. It just sends the main.js
file you're using for the main thread and passes it to (new js/Worker ...
@john not sure what you are up to, but doing anything dynamic in :advanced
is really asking for trouble 😉
but it apparently does so carefully, because I'm getting all kinds of "document not defined" errors when trying to require in a repl connected to webworker
I can use standard cljs functions in the webworker, but I can't do any new requiring, as apparently Object.goog.importScript attaches imported scripts to the dom
wacky
I want to flip the model inside out. Do all "main" work, including the repl, in the worker, and offload to the UI thread only UI updates.
but given that a worker is basically a sandboxed VM that just can't do some things the main thread can do
You'd probably have to implement some library that proxies necessary dom interactions and other restricted resources for it to be useful probably
I'm envisioning one master worker, which the main UI thread spawns and monitors. You work on the master thread and spawn subworkers from there.
I would read how react native does that, they had to implement a bridge between JS engine and native platform
Yeah, I've been seeing a lot of web worker bug complaints over on the react-native issue trackers
what's a shame is that js/importScripts
is available in the WorkerGlobalScope
. cljs just wants to use Object.goog.importScripts
which instead references the dom, apparently
ah that is not js/importScripts
.. it is actually goog.importScripts_
something entirely different
do you know if any way I can monkey patch the require/importScript pipeline on the webworker to make it use js/importScript?
ah hehe wait ... you are calling (require 'something)
in the REPL .. that calls eval
but (set! (.-CLOSURE_IMPORT_SCRIPT js/self) (fn [x] (js/importScripts x)))
should do it
well you need to solve the second problem still, the main threads still needs to update the code as well
@thheller so I need to think about this. In what ways do you think their environments can get out of sync? Because both the main thread and the worker thread are using the same compiled main.js
.
so there's state. I'm creating a new datatype that auto syncs all state changes to workers that have access.
so If you send a call to the remote thread that references local state, when the remote end calls the state, it will hopefully access the local version of the synced datastructure
When a parent worker inits a "shared atom" it populates the downstream environment with a new var corresponding to the one in the parent worker.
treat it like a client->server model, the UI is the server, the worker is the client. you update some code in the client, that code creates some data and sends it to the server
in the repl, yes. But if your "update" is to the source code, once you reload the page the code is reloaded in both contexts. And how often does static code, when not using a repl, generate new functions?
I mean, what will React.render(foo)
do to the environment, when not at the repl... ah, perhaps anonymous functions / closures?
You generate an anonymous function at run time. It will have a set of arities not available to the receiving environment, right?
so a few days ago I was discussing you with you and others this whole idea about putting a repl in a webworker
I'm just running a (.call ...
on the compiled javascript from the forms I ship to the worker.
So I'm trying to figure out how much milage I can get on just that alone, without the self hosted option.
So in this scenario, dynamicity will be much more constrained than with the other, but you get :advanced
compilation
so, say you define some asynchronous (search-wikipedia ...
function. It updates a shared atom sa
. You send off that function with (send sa search-wikipedia "cats")
and it populates sa
... at some future point, the parent thread will be able to see the results in sa
because search-wikipedia
is defined in both contexts, referring to the sa
var in both contexts, the function "just works"
I would do this as (.postMessage my-worker (pr-str {:action :search-wikipedia :query "cats"}))
and (do-action msg)
with (defmulti do-action :action) (defmethod do-action :search-wikipedia [{:keys [query]}] ...)
I like the idea of doing a simple (map #(send sa %) (take 10 (cycle [ten-second-job])))
and watch that spin up a pool of four workers. All without any user code required.
And to send-off
and arbitrary function with a simple (send-off sa ...
without any extra user code required.
so define your (defmethod long-running-functions :foo [...])
instead of (defn foo [...])