Fork me on GitHub
#clojurescript
<
2015-12-18
>
vipaca00:12:58

Do clojurescript projects still require [org.clojure/core.async "<VERSION>"] in project.clj?

jjconti01:12:44

how can i formate a timestamp in hiccup?

krchia02:12:06

anyone used fabric.js together with om before?

krchia02:12:41

i can use some simple functions from just fabric.js

krchia02:12:17

but i can’t figure out how to render a fabric canvas in an om component

johannjohann03:12:24

@krchia sorry for the delay, what do you have sofar?

krchia03:12:03

i got it now, but now im not too sure how om works

johannjohann03:12:53

are you familiar with react?

krchia03:12:31

no, i’m learning both at the same time

krchia03:12:21

if i’m not wrong, om is a way of making separate components

krchia03:12:41

and they all read/write from app-state.. something like that right?

noonian03:12:13

Om is changing a lot right now, so it is important to distinguish between the upcoming version “Om.next”, which is in alpha right now, and “Om.now” which the examples from Om’s readme are using.

johannjohann03:12:37

hah solid point

noonian03:12:19

But they both provide ways to help manage your client applications state; Om.next provides a more complete package but is also more opinionated and there are more concepts you will need to understand to get started.

krchia03:12:31

i think i have more low level problems right now

krchia03:12:33

like syntax

krchia03:12:15

i have a dom/canvas in om/IRender

krchia03:12:58

then i have to wrap it with fabric like so (def canv (new js/fabric.Canvas “canv-element”))

krchia03:12:16

and i can’t refer to canv inside the component for fabric method calls..

krchia04:12:20

if i have an (.add canvas img) function, where should i place it in the om component?

johannjohann04:12:22

so this is a nice introduction to reacts life cycle methods

johannjohann04:12:19

is this a helpful gist or is it confusing to see the example in js? https://gist.github.com/sebmarkbage/6f7da234174ab9f64cce

johannjohann05:12:09

fabric wants a mounted dom node

johannjohann05:12:44

and using react life cycle methods you can can hand off the dom node when its 'ready' if that makes sense

krchia05:12:15

im not really sure what’s happening when i call a function like (.add xx), i don’t know where fabric stores the state

krchia05:12:26

so i can only can use fabric method calls on a mounted dom node? how can i update the state inside the om component then?

krchia05:12:04

maybe i should put aside om for now and just work with fabric.js

krchia05:12:13

im not even sure if what im asking makes sense

johannjohann05:12:34

it makes sense, but i just need a little more info to be helpful

johannjohann05:12:29

sure there are examples of people using om and canvas lemme see if i can find a good one for you

krchia05:12:01

i have plenty of those examples

krchia05:12:15

i.e. goya, but not one using fabric.js

krchia05:12:07

i’m trying to figure where i can put in (.add canv rect) in line 70 inside the om component main-canvas

johannjohann05:12:16

particularly this line >The DOM node associated with this component can be retrieved by using (om.core/get-node owner)

krchia05:12:59

i get "Warning: ReactMount: Root element has been removed from its original container. New container:"

krchia05:12:25

i think making a fabric wrapper around the original canvas elements does some funny things

martinklepsch10:12:50

@jindrichm: I'll try to answer simple_smile

martinklepsch10:12:17

@jindrichm: let me know if that helps simple_smile

dmi3y11:12:29

Hi guys. I’m trying to get cljs, nodejs and core.async play nicely together but can’t load core.async library for some reason. I would appreciate if anyone can help me figure out what’s wrong with my setup: https://gist.github.com/erasmas/5f212d770ef375b8bf47.

martinklepsch11:12:10

@dmi3y: I think :refer is not supported w/ :require-macros

dmi3y11:12:35

@martinklepsch: maybe, but I’m getting the same error even if I remove :require-macros

martinklepsch11:12:03

@dmi3y: what are you running to get to that stacktrace?

jindrichm11:12:45

@martinklepsch: Unfortunately, the issue prevails.

mfikes12:12:22

@jindrichm: make sure core.async lib is in your classpath when compiling

jindrichm12:12:22

@mfikes: It's listed as a dependency in project.clj. Why do you think it's missing? Wasn't it a response to @dmi3y?

mfikes12:12:51

Yes, meant @dmi3y reason being the gist indicates it can't find the files in the stacktrace

dmi3y12:12:52

Sorry, got pulled into a meeting. This issue happends when I start REPL from Cursive and doesn’t happen when I execute as rlwrap lein trampoline run -m clojure.main scripts/node_repl.clj. So I guess I need to figure out how to properly start node REPL from Cursive. Thanks all for your suggestions!

mfikes13:12:41

In the ever-persistent quest to clearly explain the constraints placed upon ClojureScript macros, I’ve updated the wiki, and felt that perhaps a new term needs to be coined to help describe it. (compilation scope for now). Here is a bit about the need for a name to describe the concept: https://gist.github.com/mfikes/1c2e701036e8caced17f And diffs to the Wiki to help clarify, using the term compilation scope for now: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure/_compare/001b020761f33a75d5e6e82b13100c2c1d616306...083d4010fc7849d795a9f0a623318385d711147c Interested in thoughts on whether this clarifies or makes it hopelessly complicated.

dmi3y13:12:46

Sorry, if that seems like a strange question but is it possible to use >!! and <!! with cljs ?

cljs.user=> (def a-channel (async/chan 1))
#'cljs.user/a-channel
cljs.user=> (async/>!! a-channel "Hello, world!")
WARNING: Use of undeclared Var cljs.core.async/>!! at line 1 <cljs repl>
TypeError: Cannot read property 'call' of undefined

mfikes13:12:23

@dmi3y: That would block the only thread right?

jindrichm13:12:06

@dmi3y: No. Since you don't have threads in JS, you cannot use thread-blocking >!! or <!!.

dmi3y13:12:27

Right, makes sense, I forgot I’m in JS land … 😊

tolitius14:12:43

@mfikes: cljs macros is definitely a blur subject coming from a backend. I think compilation scope describes it well since it has a "time" (compilation) and "place" (scope: clj / #?(:clj). I feel that one thing that you removed "Macros are written in Clojure" was helpful. It might makes sense to mention somewhere that "Macros are written in .clj or .cljc within #?(:clj ... ), and are referenced in .cljs or .cljc within #?(:cljs ... )"

mfikes14:12:47

@tolitius: Interestingly, you can write macros in .cljc within #?(:cljs …) if targeting a bootstrapped environment.

mfikes14:12:42

@tolitius: In other words, you could argue that in a bootstrapped environment, macros are written in ClojureScript. Thus the need to delicately remove “written in Clojure” while preserving the true constraint.

mfikes14:12:18

Thus the attempt to boil it down to a one-liner that might actually be meaningful (and also accurate): "ClojureScript's macros must be written in a different compilation scope than the one from where they are consumed."

dnolen14:12:40

@mfikes: I think maybe the CS-y thing to say here is that ClojureScript compilation is staged, and the ClojureScript compiler(s) disallow mixing stages into the same namespace.

mfikes14:12:39

@dnolen: Yes. That could answer the question: “Can a bootstrapped macros file itself consume macros?” and the answer is “Yes, if those macros are in a different stage”. (Reminds me mathematically of classes in non ZFC set theories for some reason.)

mfikes14:12:50

So, instead of compilation scope, use compilation stage, or even just stage if context is clear.

dnolen14:12:09

@mfikes right that’s a interesting point though probably one that’s very subtle if you haven’t really thought through the implications for bootstrapped ClojureScript

mfikes14:12:20

In bootstrapped I picture an unbounded hierarchy of stages. But yeah, I bet there are subtle things where something can fall apart simple_smile

dnolen14:12:39

worthwhile related reading for this discussion

mfikes14:12:41

Yes… they use phase. Will read.

tolitius15:12:08

@mfikes: ah.. bootstrapped, you're right. then maybe the answer to the question "so, can I do a defmacro in ClojureScript" would be "yes, but only in bootstrapped. otherwise here are the stages/phases.. where a macro can be defined. and here is.. how it can be then referenced in cljs". this is of course to only simplify the beginning "stage". I feel hiding clarity behind stages/phases could sound too "monadic" for beginners simple_smile

mfikes15:12:56

@tolitius: Yeah. I suspect there is a way to convey the rules that is both simple and accurate.

mfikes15:12:06

For some reason, I want one sentence, like "ClojureScript's macros must be defined in a different compilation stage than the one from where they are consumed."

dnolen15:12:57

@tolitius: the rules aren’t any different in bootstrapped really

mfikes15:12:58

At first blush, I can’t poke any holes in the sentence above.

dnolen15:12:09

you still have phases

dnolen15:12:29

but as @mfikes has discovered will you will get a “tower” of phases in bootstrapped

mfikes15:12:04

Right. I want the one sentence to apply to JVM and bootstrapped. A sentence that conveys the salient concept that a developer needs to know.

tolitius15:12:54

@dnolen: can you defmacro within #?(:cljs …) when not targeting bootstrapped, or you would not consider it a rule, just a different phase?

dnolen15:12:28

@tolitius: there is not semantic difference between bootstrapped and non-bootstrapped

dnolen15:12:35

it’s the same compiler

dnolen15:12:41

that means no macros in non-macro namespaces

tolitius15:12:45

@dnolen: I am still exploring the cljs universe, but I thought if you were to bring clojurescript dependency with an aot classifier, it would not compile a "defmacro" unless it is under #?(:clj ...). maybe I am just missing something obvious

dnolen15:12:17

AOT has nothing to do with this discussion really

dnolen15:12:32

the AOT artifact is just about process boot time

tolitius15:12:41

@dnolen: ok, I'll experiment further to understand it a little better. I had to wrap all the "defmacro"s in "#?(:clj …)" when switched from [[org.clojure/clojurescript "version"]] to [[org.clojure/clojurescript "version" :classifier "aot"]]. otherwise it would not compile. that's when I thought that AOT had something to do with it. although I understand that the only thing it has to do with is helping the startup/compilation time, since cljs itself is already pre compiled

dnolen15:12:52

@tolitius: you’re mixing up understanding of how ClojureScript works with environment issues

dnolen15:12:28

inability to get the AOT artifact working with Lein is why I just use Maven directly now

dnolen15:12:41

your problems have nothing to do with macros and AOT - they are unrelated

tolitius15:12:09

@dnolen: thx, I could not find an explanation why would AOT matter, env makes sense. @mfikes: didn't mean to derail the documentation improvements, we can get back to that simple_smile

dnolen15:12:01

@tolitius: eventually I need to write something actionable about the issue so it can be resolved in Lein or cljsbuild, but I’m too busy with other things.

tolitius15:12:43

@dnolen: that'd be great. until then, it gives me a good reason to try boot, and just mvn

mfikes15:12:48

For now, I think I’ll revise the page to use the term stage. More semantically on target than scope.

spinningtopsofdoom20:12:46

Writeup on my experiences making improvements to ClojureScript's HashMap implementation http://bendyworks.com/leveling-clojures-hash-maps/

spinningtopsofdoom20:12:03

Thanks hopefully this not only leads to perf improvements but wider use of Immutable HashMaps simple_smile

spinningtopsofdoom20:12:35

At least for me the new implementation made coding / debugging a HAMT a lot easier.

mfikes21:12:33

If you put the lean-map-0.3.0.jar on your classpath, it is not clear to me how to load code out of the main subdirectory within the JAR. (I’m not an expert, so asking, is this possible?)

settinghead21:12:12

which of the older browsers (IE8,9, etc) does ClojureScript officially support?

settinghead21:12:46

is there a list of supported browsers somewhere?

settinghead21:12:12

ah, overlooked that one. thanks

settinghead21:12:41

that’s good to know.

borkdude21:12:19

@settinghead: I've written a production application in it that supports IE9, haven't heard any complaints

mfikes21:12:44

The reason I ask about lean-map-0.3.0.jar and the main subdirectory is that the code you want to load is in directories that look like main/cljs/lean_map/core.cljs instead of cljs/lean_map/core.cljs.

mfikes21:12:04

load-file partially works for this, but causes an issue of one ns internally requires another

spinningtopsofdoom21:12:11

@mfikes: I'm not an expert either, from looking at other repo's I thought this was the standard way to namespace things

mfikes21:12:45

@spinningtopsofdoom: Ahh cool. If other repo’s are doing it then there must be an answer simple_smile

spinningtopsofdoom21:12:26

eg om for example simple_smile

mfikes21:12:36

@spinningtopsofdoom: Om was one of the first I looked at. Its code is at the top level from what I can see.

mfikes21:12:46

(I’m doing jar tvf on the JAR down in ~/.m2. For Om, one file of interest is om/core.cljs.)

mfikes21:12:39

Normal use would lead to this:

$ lein run -m cljs.repl.node
ClojureScript Node.js REPL server listening on 55376
To quit, type: :cljs/quit
cljs.user=> (require 'cljs.lean-map.util)
clojure.lang.ExceptionInfo: No such namespace: cljs.lean-map.util, could not locate cljs/lean_map/util.cljs, cljs/lean_map/util.cljc, or Closure namespace "cljs.lean-map.util" {:tag :cljs/analysis-error}
	at clojure.core$ex_info.invoke(core.clj:4593)
	at cljs.analyzer$error.invoke(analyzer.cljc:568)
…

spinningtopsofdoom21:12:41

Hmmm I thought I had it setup correctly, I have to head out now could you file an issue explaining the problem?

mfikes21:12:23

@spinningtopsofdoom: Yep. Will do. By the way, things work perfectly in Planck if I crack the JAR apart and skip the main directory.

spinningtopsofdoom22:12:31

ooofff thanks for the detailed feedback!

spinningtopsofdoom22:12:15

@mfikes: Found the bug I didn't have a source-paths set up on project.clj. I cut a new release version 0.3.1` with the fix. It worked on my machine 😥.

mfikes22:12:52

@spinningtopsofdoom: Yep. Works for me too.

spinningtopsofdoom22:12:42

Great let me know of any issues that come up and improvements that could be made.

magomimmo23:12:21

@jaen: when I wrote the second edition of the series I added this note at the chapter on domina:

magomimmo23:12:45

@jaen: Domina was one of the first DOM library written in CLJS and it has not been updated to follow the evolution of CLJS compiler. If you use the canonical domina release (i.e., [domina "1.0.3"]), during the compilation you'll get a warning about the fact that it uses a single segment namespace. Even if those warnings do not affect the behavior of the lib in the contest of this tutorial, I really hate warnings. So I prepared a non canonical domina release which fixes those warnings. That said, even if I would never suggest to use domina in a new CLJS project, this tutorial could be still useful to understand the way CLJS works.

jaen23:12:19

I guess it makes sense to use it with such disclaimer, I suppose.