Fork me on GitHub
#clojurescript
<
2016-09-08
>
sveri07:09:20

Hi...has someone come up with a clojurescript charting library inbetween?

tap08:09:38

I watched this talk by the author of https://github.com/dvdt/gyptis It’s clojure lib but draw on browser https://www.youtube.com/watch?v=RvZ0au1XM-w

pesterhazy08:09:31

Any tips on resolving circular dependencies when defining routes on the frontend? my.routes requires most app namespaces (because it defines routes referring to my.product/screen and my.login.screen). But I also occasionally need to refer to my.routes/routes.

pesterhazy09:09:20

I guess you need some kind of indirection

juhoteperi09:09:24

I've been using multimethods, routes defines a render-view or such and all views define their own implementations for that. routes doesn't need to require any view namespaces.

pesterhazy09:09:25

- an atom - a var manually resolved - something else?

pesterhazy09:09:45

ah a multimethod would work for that as well

pesterhazy09:09:57

super sneaky

pesterhazy09:09:45

in my.sneaky-routes: (defmulti routes identity) and in my.routes: (defmethod routes :default [_] the-routes)

juhoteperi09:09:31

that's quite different to what I use, but I guess it will work also 🙂

pesterhazy09:09:06

hackity hack 🙂

sveri09:09:01

@tap thanks for the link, but it is not quite what I am looking for.

pesterhazy10:09:33

cljs.user=> (instance? IFn identity)
false

pesterhazy10:09:19

is there another type I should use if I want to extend-protocol a protocol for functions?

pesterhazy10:09:51

js/Function !

lxsameer12:09:31

is it possible to reload the re-natal app via figwheel repl ?

rovanion13:09:14

Throwing it out here again: Has anyone worked with WebGL the same way it's possible to work with the DOM? Like figwheel+react manages to replace code in the running application without ruining its state. Right now I can replace the JS code but I have to restart the WebGL state machine to change the GPU program.

selfsame13:09:18

rovanion: check out https://github.com/kovasb/gamma for data to GLSL compilation. For scene graph stuff maybe three.js, I think textures and mesh data might have to be preloaded, but the scene graph objects could constructed from a data layer

nickt14:09:25

hey all. Is it possible to write a macro with side effects at expansion time? (defmacro [blah] (do some side effect) ~(println blargh))

nickt14:09:30

like write a file?

selfsame14:09:47

nickt yes you have a full clojure env on the macro side

selfsame14:09:55

awesome project by the way

selfsame14:09:31

you can have a registry atom in the macro ns and build up data from multiple expansions

Jeremie Pelletier14:09:55

@rovanion im using figwheel with webgl, you just have to defonce your context/state variables (or use stuartsierra’s component and defonce the system only)

Jeremie Pelletier14:09:06

that way I can modify the render logic without reloading the render state

nickt14:09:46

@selfsame awesome that will be super useful

nickt14:09:42

also I'd love feedback on that project if you have any thoughts!

len15:09:32

I am trying to pr-process a text file in the browser before sending it on to the backend, how would I even get started with such a thing

lwhorton15:09:13

I feel like i’m missing something fundamental here with closure library.. if I have to :import constructor classes, what happens with something like this:

(:import
    [goog.ui.PopupBase EventType]
    [goog.events EventType]
    )
How can i differentiate between these?

pat15:09:08

@lwhorton: import is for classes + enums

pat15:09:14

Events is a enum

lwhorton15:09:22

right, but do I have to do something like [goog.ui.PopupBase] and reference it via PopupBase.EventType so that EventType of goog.events isn’t clobbered?

lwhorton15:09:38

(since there’s no :as in import)

pat15:09:41

Ok i misunderstood

mordocai16:09:44

I could use some help with clojurescript here. This is my first "real" clojurescript project, and i'm getting an error about duplicate externs https://gitlab.com/mordocai/my-screeps/tree/clojurescript. Error: http://paste.lisp.org/display/325470. Link to the checkouts/screeps-beans is in http://README.org but its https://github.com/archlisp/screeps-beans. I'm not married to any of the existing structure, just need something that works. Goal is a discrete javascript file to be loaded/used by https://screeps.com. I think I could fix this by ditching the screeps-beans library and moving the extern directly into my project, but i'd rather use the library if possible.

mordocai16:09:11

I posted this on #beginners last night, but no one seemed to know how to help 😄

mordocai16:09:04

Also, I have commit access to screeps-beans if the problem is somewhere in there

stbgz16:09:50

hey all what’s the fastest way to test core.async code within a deftest test, it seems to me like the test was running and not waiting on the (<!) macro to finish executing

stbgz16:09:58

@darwin awesome, I’ll take a look

pat16:09:50

@mordocai it may not like you providing an extern for the global object

mordocai16:09:02

@pat Well, that is how the API I have to use works (if I am understanding you correctly). Also, the screeps-beans project that is doing the extern builds just not my project that uses it

mordocai16:09:23

I don't really know what is going on though so...

pat17:09:23

@mordocai: you can co master and comment out the global in the node extern that ships with cljs and see if that works

pat17:09:05

But fwiw the game tacking stuff onto global like that is just awful design

mordocai17:09:28

@pat Agreed. They should probably provide it as a module.

mordocai17:09:29

@pat I can go through the trouble of doing that to try it, but does that explain why screeps-beans compiles fine but my-screeps doesn't?

pat17:09:44

Does the other repo compile fine with advanced? If it does then my guess was wrong

mordocai17:09:14

@pat I think so but i'll double check

mordocai17:09:50

@pat yeah, so if I run the scripts/watch in the other repo it outputs

➜  screeps-beans git:(master) ✗ scripts/watch 
Building ...
Building ...
Copying jar:file:/home/ccarpenter/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs to release/cljs/core.cljs
Analyzing jar:file:/home/ccarpenter/.m2/repository/org/clojure/clojurescript/1.9.229/clojurescript-1.9.229.jar!/cljs/core.cljs
Compiling release/cljs/core.cljs
Compiling /home/ccarpenter/git_repos/screeps-beans/src/screeps/structure.cljs
Compiling src/screeps/memory.cljs
WARNING: Use of undeclared Var screeps.memory/store at line 21 src/screeps/memory.cljs
Compiling src/screeps/position.cljs
Compiling /home/ccarpenter/git_repos/screeps-beans/src/screeps/creep.cljs
Compiling src/screeps/spawn.cljs
Compiling src/screeps/room.cljs
Compiling src/screeps/game.cljs
Compiling src/ai/test.cljs
WARNING: Use of undeclared Var screeps.memory/store at line 43 src/ai/test.cljs
WARNING: Use of undeclared Var screeps.memory/update at line 45 src/ai/test.cljs
WARNING: Use of undeclared Var screeps.memory/memory at line 46 src/ai/test.cljs
WARNING: Use of undeclared Var screeps.memory/memory at line 47 src/ai/test.cljs
Compiling src/ai/creep.cljs
Applying optimizations :advanced to 22 sources
... done. Elapsed 13.008752139 seconds
export SCREEPS_USERNAME and SCREEPS_PASSWORD (optionally SCREEPS_BRANCH) to autodeploy code.
Watching paths: /home/ccarpenter/git_repos/screeps-beans/src

mordocai17:09:43

(this on a different computer than last night so that's why it says ccarpenter instead of mordocai)

pat17:09:54

Try to clear the warnings

pat17:09:50

Wait nvm those are cljsc warnings

mordocai17:09:44

I'm guessing this is going to come down to a stupid typo/something i'm overlooking. That's usually my experience when things are hard to figure out like this

mordocai17:09:20

FWIW it works to build without optimizations :advanced, but it obviously isn't in an ideal form to use it on http://screeps.com.

pat17:09:49

Theres an externs validation compiler option you may want to try

mordocai17:09:51

Tried this with both :on and :off with no difference:

(let [start (System/nanoTime)]
  (b/build "src"
           {:output-to "release/main.js"
            :output-dir "release"
            :optimizations :advanced
            :externs-validation :off
            :verbose true})
  (println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))

pat17:09:16

Has to be in :closure-warnings map

mordocai17:09:37

@pat So that's interesting. With it set to :off I get the same thing as before. When set to :on I get a NullPointerException seen here http://paste.lisp.org/display/325552. Running it as

(require '[cljs.build.api :as b])

(println "Building ...")

(let [start (System/nanoTime)]
  (b/build "src"
           {:output-to "release/main.js"
            :output-dir "release"
            :optimizations :advanced
            :closure-warnings {:externs-validation :on}
            :verbose true})
  (println "... done. Elapsed" (/ (- (System/nanoTime) start) 1e9) "seconds"))

mordocai17:09:02

Oh I see, :on isn't an option

mordocai17:09:08

Bad error message for that

mordocai17:09:29

Setting to :error and :warning get the same results as before, the "duplicate extern" error

mordocai17:09:44

So all three values have no effect

pat17:09:14

Try this on the repo that does compile

pat17:09:05

@mordocai it may be that closure is just silent for the working repo, this will force you to know one way or the other

mordocai17:09:24

@pat With :closure-warnings {:externs-validation :error} there is no difference in output from before (on the working repo).

pat17:09:41

@mordocai then i have no idea

mordocai17:09:26

@pat Thanks for the help anyway! At least ruled some things out.

pat17:09:29

Did you try :off with your build?

pat17:09:53

Nvm i see above.

yury.solovyov18:09:58

can clojurescript tools inline images into css as webpack does?

nickt20:09:53

when a given macro is expanding, do we have any information about the callsite?

nickt20:09:25

like the namespace from which the macro was invoked?

nickt20:09:31

I'd guess not 😛

jr20:09:18

*ns* will be bound to the calling ns at compile time

nickt20:09:19

@jr so if I reference *ns* in my defmacro body it will be bound to the calling ns for each invocation?

nickt20:09:30

awesome! thanks

timgilbert22:09:45

Say, quick question: if I do an :optimizations :none build and then follow it with an :optimizations :advanced, is it necessary / recommended to run a lein clean (or boot equivalent) in between? I suspect not, but I just thought I'd ask

rovanion22:09:56

@selfsame: Looked at that earlier but as the main README says, it's very early alpha and there's not been a lot of action since 2015.

rovanion22:09:12

So I'm a bit iffy at exposing that to my coworkers.

rovanion22:09:15

@lambdacoder Thank you, that's pretty much what I figured after thinking about it for a while. But then my thoughts were that you could only do this to the CPU part of the program, that changing any GLSL would necessarily have to mean a restart of the WebGL state machine. But maybe I'm wrong on that?

rovanion22:09:31

@lambdacoder You don't happen to have a PoC lying around?

rovanion22:09:48

Gonna watch stuarts presentation on components.