Re: [ClojureScript] Trying hello-world tutorial and get "Error building classpath" - Internet needed?

2021-07-04 Thread Gary Verhaegen
In the vast majority of cases, yes, the dependencies are platform-independent 
and copying over the .m2 directory should work. Also note that you only need to 
do that once per version of your deps.edn file, i.e. as long as you don't 
change your deps.edn file you should be able to work completely offline.

Sometimes there are native dependencies, which are platform dependent. If you 
do hit that, you can still use something like Vagrant and Virtualbox to easily 
get a Linux VM on your Mac and get the Linux-specific .m2 that way.

> On 3 Jul 2021, at 15:01, oliver  wrote:
> 
> 
> Hi Gary
> 
> Thank you very much for this incredibly detailed answer!
> 
> Makes totally sense and particularly the tip with the —output-to option is 
> very helpful and exactly what I will need.
> 
> A follow-up question to the download part:
> On the machine on which I will do the development I don’t have an internet 
> connection, but I could run a mock compile on a personal machine with 
> internet access and then copy everything in the .m2 directory via USB key or 
> similar to the development computer.
> 
> The .m2 dependencies are machine-independent, right? I am asking because the 
> personal machine would be a Macbook and the development machine is a Linux 
> box.
> 
> Anyway, thanks again for all the information!
> 
> Ollie
> 
> On 3 Jul 2021, at 3:02, Gary Johnson wrote:
> 
> Hi Oliver,
> 
> clj is a shell script that provides an interface to several functions within 
> the clojure JAR file. The first time you run it, clj has to download the 
> clojure JAR and store it in your $HOME/.m2/repository directory tree for 
> later use.
> 
> Every time you run clj, it will check the current directory to see if there 
> is a deps.edn file present. If so, it will read the :deps map from it to 
> determine which dependency libraries need to be made available on your JVM 
> classpath. Any which have not already been downloaded to $HOME/.m2/repository 
> will be downloaded at this point and save for later use.
> 
> Note, in particular, that to compile clojurescript to javascript, you must 
> include the clojurescript JAR in your deps.edn file. This will ensure that it 
> is downloaded to $HOME/.m2/repository and added to your classpath, so that 
> the `--main cljs.main --compile hello-world.core --repl` command can be 
> evaluated successfully.
> 
> At a minimum, you will need to add this to your project's deps.edn file in 
> order to run the clj command you provided:
> 
> ```clojure
> {:paths ["src/cljs"]
>  :deps  {org.clojure/clojure   {:mvn/version "1.10.3"}
>  org.clojure/clojurescript {:mvn/version "1.10.866"}}}
> ```
> Next, create the file src/cljs/hello_world/core.cljs, containing this code:
> 
> ```clojure
> (ns hello-world.core)
> 
> (defn say-hello []
>   (js/alert "Hello from CLJS!"))
> 
> (say-hello)
> ```
> 
> At this point, your directory tree should look like this:
> 
> .
> ├── deps.edn
> └── src
> └── cljs
> └── hello_world
> └── core.cljs
> 
> Now you are ready to compile core.cljs into Javascript. Let's run the command 
> you provided in your original post:
> 
> clj -M --main cljs.main --compile hello-world.core --repl
> 
> This will read deps.edn, make sure you have the clojure and clojurescript 
> JARs in $HOME/.m2/repository (or download them if not), spin up a JVM with 
> src/cljs and both JARs on its classpath, load the cljs.main namespace (from 
> the clojurescript JAR), and run its -main method with ["--compile" 
> "hello-world.core" "--repl"] as its arguments. This -main method is the 
> entrypoint function for the clojurescript compiler, which then loads the 
> hello-world.core namespace (found under src/cljs/hello_world/core.cljs <-- 
> note that - in namespaces becomes _ in filenames). The clojurescript compiler 
> then compiles your code into javascript under the out/ directory by default. 
> Finally, since you passed the "--repl" argument, a web browser window will be 
> opened and pointed to http://localhost:9000, which loads up a default webpage 
> provided the clojurescript JAR file, that contains javascript code to connect 
> back to your clj REPL, so that the browser can act as the runtime environment 
> for your javascript code as well as any forms that you type at the REPL.
> 
> Since your code included a call to (say-hello) at the toplevel, this function 
> will be run as soon as the page loads, which will display a javascript alert 
> box in your browser window with the text "Hello from CLJS!" in it.
> 
> To verify that everything is working correctly, you'll want to use require 
> and in-ns to load and navigate to your hello-world.core namespace in the 
> REPL. Then you can run the (say-hello) function again interactively. Here's 
> the command sequence you want to type:
> 
> ClojureScript 1.10.866
> cljs.user=> (require 'hello-world.core)
> nil
> cljs.user=> (in-ns 'hello-world.core)
> nil
> hello-world.core=> (say-hello)
> nil
> 
> If everything 

Re: [ClojureScript] Can ClojureScript transpile to plain JavaScript?

2021-07-04 Thread Gary Verhaegen
Yes; transpiling to plain JavaScript is really what ClojureScript was designed 
to do. You can also very easily call existing JavaScript from ClojureScript 
code, so you may be able to start using ClojureScript without having to rewrite 
all of your existing code.

> On 1 Jul 2021, at 15:52, Oliver Baumann  wrote:
> 
> 
> Just figuring, it might be good to check whether I can achieve with 
> ClojureScript what I want to do:
> 
> We have a website with some JavaScript functionality (some reading of JSON 
> data, some calculations, etc).
> 
> I'm planning to (re)write and extend the JavaScript parts with ClojureScript 
> (to learn Clojure and to keep the site better maintainable). For this I would 
> like to write ClojureScript, transpile it with clj, copy the JavaScript 
> output to the web server and then view our HTML page which includes/loads the 
> JavaScript.
> 
> Feasible?
> 
> Many thanks for any pointers!
> 
> -- 
> Note that posts from new members are moderated - please be patient with your 
> first post.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojurescript+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/clojurescript/dcdad66e-a8c5-4cbd-ac56-2fb7e1ce6de1n%40googlegroups.com.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojurescript/C9911D56-64CE-4F72-890D-2FC6C9D730F0%40gmail.com.


Re: [ClojureScript] Re: Problems with Clojurescript quickstart — build fails

2018-01-29 Thread Gary Verhaegen
It seems it's not finding the repl.clj file, which would point to an incorrect 
classpath definition.

There's not much we can do to help without access to your project.clj file.

>From the stack trace, it looks like you may have incorrectly configured the 
>source paths (default is "src", I think), or your repl.clj files starts with 
>"(ns cljs.repl".

By default, if your repl.clj files starts with that, the file itself needs to 
be at src/cljs/repl.clj for Java to find it.

> On 26 Jan 2018, at 20:18, Johannes  wrote:
> 
> Is there a way to use leiningen with Clojurescript and Java 9 too.
> 
> If I try this from the Quickstart:
> lein run -m clojure.main repl.clj
> 
> I get the following stack trace ...
> 
> clojure.lang.Compiler$CompilerException: java.io.FileNotFoundException: Could 
> not locate cljs/repl__init.class or cljs/repl.clj on classpath., 
> compiling:(/Users/johannes/tmp/hello_world/repl.clj:1:1)
>  at clojure.lang.Compiler.load (Compiler.java:7391)
> clojure.lang.Compiler.loadFile (Compiler.java:7317)
> clojure.main$load_script.invokeStatic (main.clj:275)
> clojure.main$script_opt.invokeStatic (main.clj:335)
> clojure.main$script_opt.invoke (main.clj:330)
> clojure.main$main.invokeStatic (main.clj:421)
> clojure.main$main.doInvoke (main.clj:384)
> clojure.lang.RestFn.invoke (RestFn.java:408)
> clojure.lang.Var.invoke (Var.java:379)
> clojure.lang.AFn.applyToHelper (AFn.java:154)
> clojure.lang.Var.applyTo (Var.java:700)
> clojure.main.main (main.java:37)
> 
> Am Freitag, 26. Januar 2018 14:55:42 UTC+1 schrieb Johannes:
>> 
>> yes, it works!
>> 
>> Thank you
>> 
>> Am Freitag, 26. Januar 2018 13:15:00 UTC+1 schrieb Thomas Heller:
>>> 
>>> You can use it with Java9 today if you add a little flag to the command line
>>> 
>>> Instead of calling
>>> 
>>> java -cp cljs.jar:src clojure.main build.clj
>>> 
>>> you call
>>> 
>>> java --add-modules java.xml.bind -cp cljs.jar:src clojure.main build.clj
>>> 
>>> That should fix it. The Java9 fix was already applied to ClojureScript 
>>> master but it was not released yet. Until then you can just use the flag.
>>> 
>>> 
 On Friday, January 26, 2018 at 10:20:03 AM UTC+1, Johannes wrote:
 Indeed, I updated to Java 9 a few day ago. Until now I didn't get any 
 problems using Clojure with Java 9. I seems I have to wait for a Java 9 
 compatible version of Clojurescript.
 
 Am Freitag, 26. Januar 2018 01:30:34 UTC+1 schrieb Phill Wolf:
> 
> The first sentence of the Quick Start says, "The only dependencies 
> required for this tutorial are an installation of Java 8 and the 
> standalone ClojureScript JAR."
> 
> The clue "Caused by: java.lang.ClassNotFoundException: 
> javax.xml.bind.DatatypeConverter" suggests you might be using Java 9.
> 
> -- 
> Note that posts from new members are moderated - please be patient with your 
> first post.
> --- 
> You received this message because you are subscribed to the Google Groups 
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojurescript+unsubscr...@googlegroups.com.
> To post to this group, send email to clojurescript@googlegroups.com.
> Visit this group at https://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.


Re: [ClojureScript] Om.Next <=> GraphQL/Relay

2016-03-13 Thread Gary Verhaegen
Any reason why you would not want to build off of the Java version?

On Sunday, 13 March 2016,  wrote:

> I'll rephrase the question that I asked in a different thread. If I start
> work on a GraphQL server that is written in Clojure, what work could I
> build off of? I see others have discussed the use of InstaParse and that
> does seem like the obvious starting point. Did anyone get very far using
> InstaParse to build a grammar for GraphQL?
>
>
>
> On Saturday, February 27, 2016 at 10:00:28 AM UTC-5, marc fawzi wrote:
> > To close the loop on the Limitations part of my GraphQL/Relay conceptual
> ealuation :)
> >
> >
> > Limitations
> > Query resolution in GraphQL is defined in the schema, which implements
> data model transformations that maybe evaluated as part of the the query,
> e.g. OrderBy, InRange, hasSomeRelation etc.
> > This carries the interesting implication that GraphQL cannot be used (on
> its own) to support the kind of cient-defined queries that require ad-hoc
> model transformations. An example would be an app that allows the user to
> slice and dice her data in an arbitrary fashion.
> > Here are the responses I got to the above:
> >
> > If we stop thinking of GraphQL as a Graph Query Language in the Graph DB
> sense, which it's not, and instead think of it as Graph-y RPC Language then
> it makes sense to use a Query DSL. The confusion beginners often have is
> with the idea implied by GraphQL, i.e. a graph query language. The chosen
> name is GraphQL where Q stands for "Query" but in reality it's a "Graph-y
> RPC Language" or "Graph-based Extensible API Protocol."
> > >><<
> > So my question is do we have something similar or better than
> GraphQL/Relay in the Clojure/Script world? Om.Next/Datomic?  or is that a
> very different model? asking naively since I've not had a chance to play
> with Om.Next/Datomic yet, but is there a reason to? Can it be better than
> the GraphQL/Relay combination? If so, in what ways?
> >
> >
> >
> >
> > On Thu, Feb 25, 2016 at 6:19 PM, Marc Fawzi  > wrote:
> >
> >
> > Didn't take me long before I zoomed in on the dark side of GraphQL :)
> like a magnet
> >
> >
> > See under "Limitations"
> >
> >
> > https://gist.github.com/idibidiart/49a095b6bc528638f34f
> >
> > Sent from my iPhone
> >
> >
> >
> > On Feb 19, 2016, at 8:41 PM, Marc Fawzi  > wrote:
> >
> >
> >
> >
> >
> > So, I'm having great fun playing with an in-house implementation of the
> GraphQL spec (extended to do more, and some custom-y things) and I wanted
> to share the rational for our adoption of GraphQL/Relay with the
> Clojure/Script in hope that I can see how it differs from Om.Next + Datomic
> (or whatever Om.Next uses on the backend) from enlightened folks
> >
> >
> > For me this kind of 'deep architecture' is unattainable via things like
> Reagent/Reframe and Om.Next is probably (I'm thinking out loud here) the
> closest option for those of us who like to stay within the Clojure/Script
> ecosystem.
> >
> >
> > Please feel free to take this post apart
> >
> >
> > https://gist.github.com/idibidiart/49a095b6bc528638f34f
> >
> >
> > and let us know if we're missing anything.
> >
> >
> > I focused on Redux + Reselect in my critique but the same applies to
> Reframe, which is what Redux/Reselect aims to mimic in the JS world.
> >
> >
> > Also, for another perspective on this topic of comparing advances in JS
> to state of the art in ClojureScript, someone from the GraphQL team tweeted
> this last week, and so I feel obliged to include it, although I've yet to
> read it myself (life is short)
> >
> >
> >
> http://hueypetersen.com/posts/2016/02/13/om-next-from-a-relay-graphql-perspective/
> >
> >
> >
> > Cheers
> >
> >
> > Marc
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojurescript+unsubscr...@googlegroups.com .
> To post to this group, send email to clojurescript@googlegroups.com
> .
> Visit this group at https://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at https://groups.google.com/group/clojurescript.


Re: [ClojureScript] Extending protocol to an existing JavaScript type

2015-09-03 Thread Gary Verhaegen
Coukd you please post the code that produces that warning? Ideally a
minimal case.

On Thursday, 3 September 2015, Scott Nelson  wrote:

> Why is this bad practice?  I'm trying to extend a protocol to js/Function
> and I get the following warning:
>
> WARNING: Extending an existing JavaScript type - use a different symbol
> name instead of js/Function
>
> I'm trying to create a function that is polymorphic based on the input
> type (could be a function, map or vector) and I thought protocols were the
> best way to do that.  Should I instead create a multimethod that dispatches
> on (type arg)?
>
> Thanks!
>
> -Scott
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojurescript+unsubscr...@googlegroups.com .
> To post to this group, send email to clojurescript@googlegroups.com
> .
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: Sent data to the server - empty params

2015-08-14 Thread Gary Verhaegen
It's difficult to tell without the server code, but I think this is a
misunderstanding about what HTTP params are. In your manual case, you
are sending www-url-encoded post params, while in your cljs example
you're sending a request with an EDN body. These two approaches yield
very different HTTP requests at the wire level, and your server code
has to unpack them differently. Depending on your Ring wrappers, the
EDN you send from cljs will probably be in the :body (not :params)
attribute of the ring request, and may be either a Clojure map or a
string.

On 12 August 2015 at 15:31, Édipo Luis Féderle edipofede...@gmail.com wrote:
 On Wednesday, August 12, 2015 at 10:15:46 AM UTC-3, Édipo Luis Féderle wrote:
 Hello again,

 I am working with base om tutorial by David Nolen*. But I am with a problem 
 when I try send a POST to my back-end. Basically I use the same code from om 
 tutorial. I test back-end separately e it works as expects:

 curl -X POST -d foo=bar http://localhost:10555/posts
 Params: {:foo bar}%

 Bu when I trying from ClojureScript the params is empty. I do:

 Code from Om tutorial:

 (def ^:private meths
   {:get GET
:put PUT
:post POST
:delete DELETE})

 (defn edn-xhr [{:keys [method url data on-complete]}]
   (let [xhr (XhrIo.)]
 (events/listen xhr goog.net.EventType.COMPLETE
   (fn [e]
 (on-complete (reader/read-string (.getResponseText xhr)
 (. xhr
   (send url (meths method) (when data (pr-str data))
 #js {Content-Type application/edn}

 The request:

   (edn-xhr
{:method :post
 :url (str posts)
 :data {:name Foo Bar}
 :on-complete
 (fn [res]
   (println server response: res))})
   )

 ;;= server response:

 I don't figured out whats is the problem here. If I missed some important 
 information in this post, please, let me know.

 Thanks in advance.

 David Nolen*

 On Wednesday, August 12, 2015 at 10:15:46 AM UTC-3, Édipo Luis Féderle wrote:
 Hello again,

 I am working with base om tutorial by David Nolan. But I am with a problem 
 when I try send a POST to my back-end. Basically I use the same code from om 
 tutorial. I test back-end separately e it works as expects:

 curl -X POST -d foo=bar http://localhost:10555/posts
 Params: {:foo bar}%

 Bu when I trying from ClojureScript the params is empty. I do:

 Code from Om tutorial:

 (def ^:private meths
   {:get GET
:put PUT
:post POST
:delete DELETE})

 (defn edn-xhr [{:keys [method url data on-complete]}]
   (let [xhr (XhrIo.)]
 (events/listen xhr goog.net.EventType.COMPLETE
   (fn [e]
 (on-complete (reader/read-string (.getResponseText xhr)
 (. xhr
   (send url (meths method) (when data (pr-str data))
 #js {Content-Type application/edn}

 The request:

   (edn-xhr
{:method :post
 :url (str posts)
 :data {:name Foo Bar}
 :on-complete
 (fn [res]
   (println server response: res))})
   )

 ;;= server response:

 I don't figured out whats is the problem here. If I missed some important 
 information in this post, please, let me know.

 Thanks in advance.

 --
 Note that posts from new members are moderated - please be patient with your 
 first post.
 ---
 You received this message because you are subscribed to the Google Groups 
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Client-only Applications

2015-07-24 Thread Gary Verhaegen
On Thursday, 23 July 2015, Gary Schiltz gary.schi...@gmail.com wrote:

 If I were writing it in Swing for the desktop, I'd create a top level
 frame, populate it with a bunch of nested panels to group widgets like
 buttons, text fields, text areas, etc, use some layout managers to make it
 display nicely when resized, and attach event listeners to the interactive
 widgets. I could use seesaw (https://github.com/daveray/seesaw) to write
 in Clojure instead of Java to interact with Swing. Is there an equivalent
 ClojureScript library that similarly interacts with some JavaScript widget
 library?


React/Om works mostly like that, except that you use CSS as your layout
manager. I'm not too sure about accessing files directly from a webpage,
though. There may be security restrictions there.

If you want to do anything with web technologies, you really have to spend
some time learning HTML and CSS, even if you don't intend to write them
yourself. Maybe in the future there will be rich enough sets of premade
widgets, but my feeling is that at this point you have to understand your
compilation target.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Exponential compile times on minor edits

2015-07-24 Thread Gary Verhaegen
In general it is better to read that kind of deeply nested, big structures
as EDN at runtime than to compile it directly as part of the code. (This is
also true for JVM Clojure.)

On Thursday, 23 July 2015, Timothy Pratley timothyprat...@gmail.com wrote:

 FYI this is caused by
 [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a
 [:a [:a [:a [:a]]
 which ClojureScript turns into nested data + function calls
 -
 https://github.com/google/closure-compiler/issues/1049

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Immutable refs to mutable values

2015-07-13 Thread Gary Verhaegen
Have you already seen the Are we there yet? presentation from Rich
Hickey? I found it quite enlightening on the subject of immutability.

With regards to the dom, I think it's more about having the application
state at any point in time being represented by an immutable data
structure, and modeling time as a succession of these structures, with
atoms providing the link between these successive structures, or the
identity. If the dom only contains derived state, then we don't really care
that it's mutable, and we can actually abstract that mutation away like om
and the other react wrappers are doing.

As to how to translate all of that to JS, well... I'd look into
omniscient.js, but I've only taken a cursory glance at it. At this point
all I can say about it is that if I had to use JS, that would be the first
library I would evaluate.

On Sunday, 12 July 2015, Marc Fawzi marc.fa...@gmail.com wrote:

 In JS we don't have native persistent data structures and the ES6 const
 keyword only gives us shallow immutability without any of the gains of
 persistent data structures. ImmutableJS is nice but existing libraries
 expect regular JS maps and arrays. So what i have been thinking is to use
 ES6 Proxy with a Frozen reference and that way all writes go to the Proxy
 object while all reads come from a diffing operation on Proxy and original
 object, thus giving us some form of immutability. For now, however, I've
 implemented it as deep freezing the referenced object and using HTML5
 structured cloning algorithm for when a mutable clone is desired. This is
 admittedly half assed but it allows me go cleanly isolated all shared
 mutable state into an atom like structure in JS. So far so good and it has
 helped a lot with my D3 app since D3 charts can be 2000 lines long with a
 ton of global var use, which makes them very hard to debug, which is now
 all eliminated.

 Without that i couldnt implement the great ideas I'm learning from
 ClojureScript in my JS work.

 Sent from my iPhone

  On Jul 12, 2015, at 8:44 AM, Matt Ho matt...@gmail.com javascript:;
 wrote:
 
  What problem are you looking to solve here?
 
  My take is that immutability is a design pattern rather than something
 enforced by the language constructs.  If you want the language constructs
 to enforce immutability, Haskell is an excellent choice.  Even Elm (a
 Haskell like language) treats immutability as a design pattern rather than
 a language construct.
 
  For me, immutability is a design pattern, much like FP, intended to
 simplify how we reason about apps.  I think Om, Reagent, Flux, and Elm are
 all excellent examples of the power of immutable thinking.  For comparison,
 the mutable frameworks would be Ember, Angular, and Backbone.
 
  M
 
  --
  Note that posts from new members are moderated - please be patient with
 your first post.
  ---
  You received this message because you are subscribed to the Google
 Groups ClojureScript group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojurescript+unsubscr...@googlegroups.com javascript:;.
  To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
  Visit this group at http://groups.google.com/group/clojurescript.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Immutable refs to mutable values

2015-07-11 Thread Gary Verhaegen
The point is to have controlled, slightly exceptional mutation, instead of
rampant mutation.

In other words, you as a snippet of code that calls other code know whether
you pass in a mutable value (an atom), and so you need to be careful, or
you pass in an immutable valie (anything else from the Clojure world) and
you can count on the code you're calling not to modify it.

In the particular case of JavaScript, this distinction is really great for
callbacks, among others.

Clojure recognizes that mutation is both useful and complex, so it needs to
be available, but not the default.

On Sunday, 12 July 2015, gvim gvi...@gmail.com wrote:

 On 11/07/2015 21:54, Marc Fawzi wrote:

 What I was trying to say (I think) is the need for shared mutable state
 be it in an atom or in a DOM tree puts in doubt the idea that
 immutability in and by itself is of great benefit.

 I'm trying to find out how immutability and mutability can co-exist
 without undermining each other conceptually. I am sure there are many
 sane patterns.


 I also had my doubts about this, though from a less advanced perspective.
 The same could be said of mixing Clojure and Java, though, so you're really
 questioning the whole edifice of Clojure not just its application with
 atoms in Javascript.

 gvim


 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 --- You received this message because you are subscribed to the Google
 Groups ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] In Om, why does transact not update cursor value.

2015-05-28 Thread Gary Verhaegen
Try @cursor ?

On Tuesday, 26 May 2015, John Chijioke Umeasiegbu johnben...@gmail.com
wrote:

 Hi David,

 Then the name should be more like om/cached-value or om/init-value. It's
 very misleading as om/value. And I suggest there should be a name for
 getting the current value as having to do (get-in @(om/state cursor)‎
 (om/path cursor) ) is very boring.
 Moreover, I still have not found a great need for om/value as it's
 currently implemented.

 WDYT?

 John.



   *From: *David Nolen
 *Sent: *Monday, May 25, 2015 7:12 PM
 *To: *clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');
 *Reply To: *clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');
 *Subject: *Re: [ClojureScript] In Om, why does transact not update cursor
 value.

 om/value is the cached value that was seen at the start of render which is
 useful to know. You need to deref if you absolutely need to see what the
 current value is.

 David

 On Mon, May 25, 2015 at 1:05 PM, John Chijioke johnben...@gmail.com
 javascript:_e(%7B%7D,'cvml','johnben...@gmail.com'); wrote:

 When a transact has happened to cursor successfully. Why does (om/value
 cursor) not return the current value in (om/state cursor) at (om/path
 cursor)?

 John.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


  --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups ClojureScript group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojurescript/Ax3mO6oJFu4/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.

  --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Vim + Fully functioning REPL + Auto reloading

2015-05-19 Thread Gary Verhaegen
So, of course, first time I try this again after posting, it does not
work anymore, because my fireplace.vim is too up-to-date. The
:Piggieback command in Vim results in a not so helpful
IllegalArgumentException No value supplied for key:
weasel.repl.websocket.WebsocketEnv, which is due to a change in
Piggieback API. The latest fireplace would presumably work with the
latest Piggieback, but chestnut lags a bit behind.

So to get chestnut to work with Vim and the latest fireplace, one has
to change the fireplace code a bit to reflect the older Piggieback
API: at line 300 in plugin/fireplace.vim you need to change

let response = connection.eval('(cemerick.piggieback/cljs-repl'.arg.')')

to

let response = connection.eval('(cemerick.piggieback/cljs-repl
:repl-env '.arg.')')

Since this is not a very good solution if you are working with
multiple projects, some of which use an older Piggieback and some
others a newer one, a less invasive solution is to change step 4 in my
previous message to be:

:Piggieback :repl-env (weasel.repl.websocket/repl-env :ip 0.0.0.0 :port 9001)

Happy vimming!

On 18 May 2015 at 15:06, Gary Verhaegen gary.verhae...@gmail.com wrote:
 You can get Vim to work with Chestnut today [1] :


 Open vim
 Back in the terminal, run lein repl
 In the repl, do (run)

 In vim, open the cljs file and do

 :Piggieback (weasel.repl.websocket/repl-env :ip 0.0.0.0 :port 9001)

 Open browser to http://localhost:10555/

 In vim, cqc (js/alert woohoo!)


 It is important to respect the order of the steps; in particular, something
 within Vim breaks if you try to evaluate anything (step 6) before connecting
 a browser (step 5).

 I have only tested that with Chestnut stable, so pretty old versions of
 ClojureScript (0.0-2511) and Om (0.8.0-rc1) by now (and Clojure 1.6.0, so no
 cljc). Still feels awesome, though.

 [1]:
 https://m.reddit.com/r/Clojure/comments/2kojth/vimfireplace_and_chestnut_now_working/

 On Sunday, 17 May 2015, Tristan Strange tristan.stra...@gmail.com wrote:

 Hi,

 Has any progress been made with this?

 I've just tried a Chestnut and a Tenzing template and have been unable to
 connect to a browser REPL via Vim fireplace in either environment.

 Many thanks,
 Tristan

 On 23 February 2015 at 18:00, Alan MacDougall alanmacdoug...@gmail.com
 wrote:

 On Monday, February 23, 2015 at 8:44:06 AM UTC-6, Tristan Strange wrote:

 what's the simplest means of configuring a project that allows me to
  both:
 
  - Evaluate expressions from Vim to a browser based REPL
  - Have figwheel style reloading files.

 I recommend using Figwheel's REPL within a screen or tmux instance, and
 use vim-slime to push to it.

 https://github.com/jpalardy/vim-slime

 I use this approach for anything REPL-like, from ClojureScript to Pry (a
 Ruby REPL) to shell scripting.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.


 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Vim + Fully functioning REPL + Auto reloading

2015-05-18 Thread Gary Verhaegen
You can get Vim to work with Chestnut today [1] :



   1. Open vim
   2. Back in the terminal, run lein repl
   3. In the repl, do (run)
   4.

   In vim, open the cljs file and do

   :Piggieback (weasel.repl.websocket/repl-env :ip 0.0.0.0 :port 9001)

   5.

   Open browser to http://localhost:10555/
   6.

   In vim, cqc (js/alert woohoo!)


It is important to respect the order of the steps; in particular, something
within Vim breaks if you try to evaluate anything (step 6) before
connecting a browser (step 5).

I have only tested that with Chestnut stable, so pretty old versions of
ClojureScript (0.0-2511) and Om (0.8.0-rc1) by now (and Clojure 1.6.0, so
no cljc). Still feels awesome, though.

[1]:
https://m.reddit.com/r/Clojure/comments/2kojth/vimfireplace_and_chestnut_now_working/

On Sunday, 17 May 2015, Tristan Strange tristan.stra...@gmail.com wrote:

 Hi,

 Has any progress been made with this?

 I've just tried a Chestnut and a Tenzing template and have been unable to
 connect to a browser REPL via Vim fireplace in either environment.

 Many thanks,
 Tristan

 On 23 February 2015 at 18:00, Alan MacDougall alanmacdoug...@gmail.com
 javascript:_e(%7B%7D,'cvml','alanmacdoug...@gmail.com'); wrote:

 On Monday, February 23, 2015 at 8:44:06 AM UTC-6, Tristan Strange wrote:

 what's the simplest means of configuring a project that allows me to
 both:
 
  - Evaluate expressions from Vim to a browser based REPL
  - Have figwheel style reloading files.

 I recommend using Figwheel's REPL within a screen or tmux instance, and
 use vim-slime to push to it.

 https://github.com/jpalardy/vim-slime

 I use this approach for anything REPL-like, from ClojureScript to Pry (a
 Ruby REPL) to shell scripting.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


  --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


[ClojureScript] IE8 console.log.apply

2015-04-01 Thread Gary Verhaegen
On Monday, 30 March 2015, Oliver George oli...@condense.com.au
javascript:_e(%7B%7D,'cvml','oli...@condense.com.au'); wrote:

 Hi Guys

 Is there a recommended polyfill for working with IE8?

 I'm using console-polyfill https://github.com/paulmillr/console-polyfill
 but it's not compatible with enable-console-print! because it uses .apply
 which is undefined http://stackoverflow.com/a/1262103/176453.

 (defn enable-console-print!
   Set *print-fn* to console.log
   []
   (set! *print-newline* false)
   (set! *print-fn*
 (fn [ args]
   (.apply (.-log js/console) js/console (into-array args)


 thanks, Oliver


The call to apply is there to support multiple arities in calls to Clojure
print functions. I can see three ways around the problem. The first one
would be never to call a print function with more than one argument, in
which case you could just skip the apply call:

  (set! *print-newline* false)
  (set! *print-fn*
(fn [ args]
  (js/console.log (first args

The second one would be to have your own way of turning the args into a
string, which you can then pass to console.log as its only argument. The
third one would be to just pass the array to console.log, essentially just
removing the call to apply. I have no idea how IE8 handles logging an
array, though. Other browsers handle it well.

(I don't know anything about a polyfill for that.)

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Arithmetic operations without arguments

2015-02-10 Thread Gary Verhaegen
I think the 0-arity versions of these functions have been added during the
work on reducers, to allow them to serve as reducing functions. Without
going into reducers (or transducers, for that matter!), they place a number
of requirements on reducing functions, among which that they should be
associative and have a neutral element, and that they return that neutral
element when called with no argument.

So + and * have been extended with a zero-arity version because they are
associative and have a neutral element, while - and / have not, because
altough they have a (right-hand only) neutral element, they are not
associative. (And I'm pretty sure it does not really count as a neutral
element if it only works on one side, though my algebra skills are a bit
rusted there.)

On Tuesday, 10 February 2015, J David Eisenberg jdavid.eisenb...@gmail.com
wrote:

 The following work fine in the ClojureScript REPL:

 (+)
 (*)

 and yield 0 and 1 as results. However, these:

 (-)
 (/)

 throw exceptions, the base cause being wrong number of arguments passed.

 Why this disparity? Not that I'm going to be writing code like that, as it
 is terrible programming practice. It's just a matter of enquiring minds
 want to know.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] recur error

2014-12-17 Thread Gary Verhaegen
I can't help you, but you should probably indicate your core.async version
too.

I seem to remember some warnings about mixing arbitrary versions of cljs
and core.async, so if you recently updated cljs and did not change your
core.async dep, that might be related.

On Wednesday, 17 December 2014, Andrew andrew...@gmail.com wrote:

 I've compiled and used this for a while without problems, a simple utility
 function to drain all the remaining values on a channel:

 (defn drain
   Takes all values available on a chan then returns a vector of them,
 leaving the channel empty. Compatible with cljs too. Optionally takes a
 single function which accepts a single value and will process each drained
 value with this function, while also placing original value onto the
 vector.
   [c  f]
   (go
(loop [r []]
  (alt!
   (timeout 700) r
   c ([v]
(when f
  ((first f) v))
(recur (conj r v)))

 I used this on clojurescript 0.0-2173.  When I upgraded to 0.0-2311 I now
 get the error: Can't recur here.

 Since the code didn't change, why is recur allowed in one version but not
 the other?

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] recur error

2014-12-17 Thread Gary Verhaegen
Well then - please ignore my answer too ;-)

Regarding the code, it looks fine to me, though I do not have much
experience with core.async. I would suggest a small change to the args
vector to become [c  [f]], so you can avoid the (first f) call. I would
find it more readable that way.

Also, maybe the docstring could make it clearer that it only drains the
channel temporarily ? Or that it should obly be called after the producers
stopped ? The 700 in there seems pretty arbitrary.

On Wednesday, 17 December 2014, Gary Verhaegen gary.verhae...@gmail.com
wrote:

 I can't help you, but you should probably indicate your core.async version
 too.

 I seem to remember some warnings about mixing arbitrary versions of cljs
 and core.async, so if you recently updated cljs and did not change your
 core.async dep, that might be related.

 On Wednesday, 17 December 2014, Andrew andrew...@gmail.com
 javascript:_e(%7B%7D,'cvml','andrew...@gmail.com'); wrote:

 I've compiled and used this for a while without problems, a simple
 utility function to drain all the remaining values on a channel:

 (defn drain
   Takes all values available on a chan then returns a vector of them,
 leaving the channel empty. Compatible with cljs too. Optionally takes a
 single function which accepts a single value and will process each drained
 value with this function, while also placing original value onto the
 vector.
   [c  f]
   (go
(loop [r []]
  (alt!
   (timeout 700) r
   c ([v]
(when f
  ((first f) v))
(recur (conj r v)))

 I used this on clojurescript 0.0-2173.  When I upgraded to 0.0-2311 I now
 get the error: Can't recur here.

 Since the code didn't change, why is recur allowed in one version but not
 the other?

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.



-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] clj-ajax, lib-noir and anti-forgery token

2014-12-16 Thread Gary Verhaegen
I've done a little bit of research on that after getting bitten by it too.
My understanding is that:

* CSRF basically protects against replay attacks. You need it if your users
can alter the state of your application in a bad way. It's always a
tradeoff, of course, but if you choose not to use it I would urge you to
carefully read at least the wikipedia page on the subject so you can make
an informed decision. (In my case I decided that, given the nature of the
project, this was not worth worrying about *for now* and so shut it off.)
* While it's relatively easy to do with hidden fields in forms, AJAX is
more difficult. Apparently the best practice is to put the token inside the
headers of the server responses. It might still be necessary to put one on
the page somewhere (data-* field, maybe) if the first AJAX call is not a
GET request.

On Monday, 15 December 2014, Cesare cesare.zavatt...@gmail.com wrote:

 Yes. I was wondering what is the easiest way to make it work with a single
 page cljs/reagent app.

 I was looking at:


 http://www.luminusweb.net/docs/security.md#cross_site_request_forgery_protection

 and the token is added via template ({% csrf-token %}).

 Anyway, disabling it is enough for the moment :-)

 Il giorno lunedì 15 dicembre 2014 10:00:29 UTC+1, Daniel Kersten ha
 scritto:
  I guess you would have to manually add the token as a parameter to your
 ajax call.
 
 
  On Mon, 15 Dec 2014 08:50 Cesare cesare.z...@gmail.com javascript:;
 wrote:
  Thank you so much Nico!
 
  I updated my handler.clj with the mk-defaults stuff and it works!
 
 
 
  Anyway, is it possible to perform the anti-forgery check with clj-ajax?
 
 
 
  Thanks again!
 
 
 
  Il giorno sabato 13 dicembre 2014 21:22:04 UTC+1, Nicolás Berger ha
 scritto:
 
   Cesare,
 
  
 
  
 
   lib-noir uses site-defaults from ring-defaults. site-defaults enables
 anti-forgery by default:
 https://github.com/ring-clojure/ring-defaults/blob/master/src/ring/middleware/defaults.clj#L45
 
  
 
  
 
   Until 0.9.1, lib-noir was assoc'ing {:anti-forgery false}. That's not
 true anymore:
 https://github.com/noir-clojure/lib-noir/commit/83203b12ab1421a8493301e492df6dd2ff0dabad
 
  
 
  
 
  
 
   luminus-template was updated to handle that change, doing the
 {:anti-forgery false} assoc by default. You can create a new luminus
 project, or take a look to the template to see how it's doing it:
 https://github.com/yogthos/luminus-template/blob/master/src/leiningen/new/luminus/handler.clj#L57-L69
 
  
 
  
 
   Hope it helps!
 
  
 
  
 
   Nico
 
  
 
  
 
  
 
  
 
   On Fri, Dec 12, 2014 at 8:58 AM, Cesare cesare.z...@gmail.com
 javascript:; wrote:Hi All,
 
  
 
   I'm not sure this is the right place to ask... anyway: I have a
 Luminus project with cljs template (Clojurescript + Reagent).
 
  
 
  
 
  
 
   After upgrading lib-noir (now at 0.9.5), it seems that the
 anti-forgery check is now enabled by default.
 
  
 
  
 
  
 
   How can I manage it from ClojureScript, in particular in ajax calls?
 
  
 
  
 
  
 
   At the moment I get the error Invalid anti-forgery token for POST
 calls.
 
  
 
  
 
  
 
   Thanks a lot
 
  
 
   Bye
 
  
 
  
 
  
 
   --
 
  
 
   Note that posts from new members are moderated - please be patient
 with your first post.
 
  
 
   ---
 
  
 
   You received this message because you are subscribed to the Google
 Groups ClojureScript group.
 
  
 
   To unsubscribe from this group and stop receiving emails from it, send
 an email to clojurescrip...@googlegroups.com javascript:;.
 
  
 
   To post to this group, send email to clojur...@googlegroups.com
 javascript:;.
 
  
 
   Visit this group at http://groups.google.com/group/clojurescript.
 
 
 
  --
 
  Note that posts from new members are moderated - please be patient with
 your first post.
 
  ---
 
  You received this message because you are subscribed to the Google
 Groups ClojureScript group.
 
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojurescrip...@googlegroups.com javascript:;.
 
  To post to this group, send email to clojur...@googlegroups.com
 javascript:;.
 
  Visit this group at http://groups.google.com/group/clojurescript.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 

Re: [ClojureScript] No such namespace: clojure.edn

2014-12-01 Thread Gary Verhaegen
These namespaces are (JVM-)Clojure specific. The EDN tools for
ClojureScript are in cljs.reader. As far as I know, there is no equivalent
for clojure.java.io in ClojureScript.

On Monday, 1 December 2014, Viktor Eriksson viktor.erikss...@gmail.com
wrote:

 Hi,

 This is probably a very trivial error on my part somewhere. But I tried to
 require clojure.edn and clojure.java.io in my .cljs-file. When compiling
 I get the following errors in the REPL:

 WARNING: No such namespace: clojure.edn at line 1
 /home/viktor/test/src-cljs/app/model/language.cljs
 WARNING: No such namespace: clojure.java.io at line 1
 /home/viktor/test/src-cljs/app/model/language.cljs
 WARNING: Use of undeclared Var app.model.language/slurp at line 6
 /home/viktor/test/src-cljs/app/model/language.cljs
 WARNING: No such namespace: clojure.edn at line 1
 src-cljs/app/model/language.cljs
 WARNING: No such namespace: clojure.java.io at line 1
 src-cljs/app/model/language.cljs
 WARNING: Use of undeclared Var app.model.language/slurp at line 6
 src-cljs/app/model/language.cljs


 In the JS-Console:

 Error: Undefined nameToPath for clojure.edn

 Would be very thankful for any help :)

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Re: Chestnut + core.async (chan)

2014-11-27 Thread Gary Verhaegen
This is most probably a dependency problem - i.e. not depending on the
correct versions of Clojure, ClojureScript and core.async. You'll get more
useful advice if you post the combinations (project.clj) you've tried, I
think.

Since you mention the browser console, I would guess the Clojure version
does not really matter and it's mostly the ClojureScript and core.async
versions which need to be correct.

On 27 November 2014 at 10:54, Andrew Voron volan...@gmail.com wrote:

 Well.
 I've found that if I remove all om dependencies (from project.clj and ns
 :require) - all works fine. I don't know exactly but it seems like om
 itself uses core.async but version that doesnt support transeducers (may be
 old one) and that version shades the version I try to include...

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com.
 To post to this group, send email to clojurescript@googlegroups.com.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Turning off optimization to speed compilation during development

2014-11-26 Thread Gary Verhaegen
:optimization :whitespace is only slightly slower than none in my
experience, and requires no hackery.

The best explanation I found of this was in the Clojurescript Up and
Running book, though I imagine it must be documented online too. Basically,
optimization none completely bypasses Google Closure and leaves you with
the output of the ClojureScript compiler.

One of the features of the Google compiler is that it takes all of your
files and combines them into a single one. With optimization none, you get
one file per namespace, so you need to place these files in a reachable
place and manually tell Closure (the library, not the compiler) to load
them.

Optimization whitespace basically just does the concatenation, so it is
pretty fast, and does not require a different setup as it still retains the
feature of producing a single file. It is slower than none though, so
you'll probably have to balance the costs yourself.

@david: the :none value for :optimization does not seem to be mentioned at
all on the lein cljsbuild github project. In particular, the
sample.project.clj mentions explicitly may be :whitespace, :simple or
:advanced.

On Wednesday, 26 November 2014, David Nolen dnolen.li...@gmail.com wrote:

 :advanced is only for release builds. :none is a fully supported
 option. To be honest I'm a bit surprised this is not clear after going
 through the documentation of either ClojureScript or lein cljsbuild.
 Would be happy to hear why you had difficulty finding this information
 and how we can make this point clearer.

 Thanks,
 David

 On Wed, Nov 26, 2014 at 10:09 AM, Matthew Gertner
 matt...@salsitasoft.com javascript:; wrote:
  My colleague was complaining about waiting ~20 seconds for his
 ClojureScript to compile and discovered this post on Stack Overflow:
 http://stackoverflow.com/questions/20917202/auto-building-clojurescript-files-for-compojure-app.
 In a nutshell, compilation time goes _way_ down if `optimization` is set to
 `:none`, but some hackery is needed to get the resulting JS to run. (I
 didn't check yet whether `:none` is a supported value or whether any
 unsupported value would have the same effect.)
 
  Is there some option for turning off optimization completely that we
 haven't been able to find? If not, is there some reason not to support
 this? Wouldn't it be possible to adapt the parser so that it emits runnable
 JS without any optimization at all during the dev process? The compilation
 time speedup is really significant.
 
  --
  Note that posts from new members are moderated - please be patient with
 your first post.
  ---
  You received this message because you are subscribed to the Google
 Groups ClojureScript group.
  To unsubscribe from this group and stop receiving emails from it, send
 an email to clojurescript+unsubscr...@googlegroups.com javascript:;.
  To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
  Visit this group at http://groups.google.com/group/clojurescript.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Check for interface implementation?

2014-11-25 Thread Gary Verhaegen
Furthermore, I believe satisfies? would be the correct approach in Clojure
too. It is in no way ClojureScript specific:

https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/satisfies
?

That protocols are implemented on top of Java interfaces is somewhat an
implementation details. Using instanceof for protocols is, in my view, akin
to directly using the class constructors for records instead of the
-Record form. It works and is highly unlikely to change in future
versions, but is still technically an implementation detail that you should
not rely on.

On Tuesday, 25 November 2014, adrian.med...@mail.yu.edu wrote:

 Interfaces are part of Java and can be defined and implemented on data
 types you define in JVM Clojure as an interop facility. But they are not
 part of the Clojure programming language in the same way protocols are.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Clarity about when to require when fully qualifying

2014-11-20 Thread Gary Verhaegen
I'd say the second option. The first one probably works by accident because
of a transitive dependency on goog.events somewhere.

On Wednesday, 19 November 2014, Colin Yates colin.ya...@gmail.com wrote:

 I have code which references the fully qualified
 goog.events.EventType/RESIZE. I haven't required goog.events.EventType.

 When it compiles, I get a WARNING: Use of undeclared Var
 goog.events.EventType/RESIZE ... but the code works fine (e.g. reacts
 correctly to the browser resizing).

 If I import goog.events.EventType then the warning goes away and I can
 reference geet/RESIZE assuming I referred [goog.events.EventType :as
 geet].

 What is the correct thing to do here?

 Thanks!

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] multiple protocol definitions in a single namespace

2014-10-27 Thread Gary Verhaegen
Protocols do not create new scoping, so, no, you cannot have two protocols
with identical method names in the same namespace.

Regarding your bug, it might have been that, or it might be that merge does
not preserve the type of the record and produces a map. I'm not sure what
the expected behaviour is here, especially since you do not mention the
order of arguments passed to merge.

On Saturday, 25 October 2014, Oliver Mooney oliver.moo...@gmail.com wrote:

 Hi all,

 Do multiple protocol definitions in the same namespace have name
 collisions if they share function names? E.g. something like:

 (defprotocol
 First
 (protofun-one [arg1])
 (protofun-two [arg1]))

 (defprotocol
 Second
 (protofun-one [arg1 arg2])
 (protofun-two [arg1 arg2]))

 I had to rename the second declarations for the compiler to find them,
 even though the type it was dispatching on was different (not to mention
 the arities being different, but presumably on the type counts for
 dispatching).

 Discovering this was followed up with one of the most infuriating bugs
 ever, where I was using merge to update a record with a map in a factory
 function, but after doing so the type was no longer being dispatched on
 properly (I was receiving errors like No protocol method [...] defined for
 type : [object Object]. This was resolved by commenting out the merge from
 the factory function, re-compiling, un-commenting the merge function,
 re-compiling again and then it worked (I'd tried a lein clean previously).

 Any hints on debugging this kind of stuff would be appreciated! Or does it
 all flow from my having two protocols with overlapping function names
 defined in the same namespace?

 Thanks,
 Oliver.

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] (def foo 1) (set! foo 2) ;; this works on ClojureScript?

2014-10-26 Thread Gary Verhaegen
Also keep in mind that defs are *global* names, even if the def form
appears inside another form. They are really meant for static (immutable)
values.

So, something like

(defn foo []
  (def a {})
  ...)

does NOT define a local variable a within foo, but a global a.

On the other hand,

(defn foo []
  (let [a (atom {})]
..))

does define a local name for a mutable reference.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] (newbie) Om/reagent (and react) clarity questions

2014-10-25 Thread Gary Verhaegen
I really like quiescent. I don't know why it's almost never mentioned in
these discussions.

On Saturday, 25 October 2014, Matt Ho matt...@gmail.com wrote:

 We ended up with a similar path with other folks that posted.  We started
 with Om, but found it brought with it a lot of incidental complexity.
 Switching to Reagent has been very simple and we've been very happy with
 the transition.

 For us, the code is understandable quickly, feels like less of a burden to
 maintain, and productivity has gone up substantially

 M

 On Thursday, October 23, 2014 6:04:31 AM UTC-7, Colin Yates wrote:
  (apologies if I have overlooked any of this in the docs, it isn't from
 lack of reading, more reaching saturation point - RTFM is a perfectly good
 response if it contains a link to the relevant bit :))
 
  My use case is that I have a non-trivial single page app. Inside this
 app there are a number of distinct areas, for a completely made up domain
 of car rental:
   - searching for/editing/adding a new customer
   - searching for/editing/adding a car
   - assigning a car to a customer
   - receiving a car from a customer
   - removing a car due to maintenance/crash
   - various reports - top 10 customers, top 10 cars etc.
   - and so on
 
  Each functional area is pretty unrelated from the others. Inside each
 functional area there are individual components that all need to talk to
 each other.
 
  Is it true that om really wants to manage the entire application state
 in a single atom. So we might have an atom map structured with keys
 referencing each functional area {:car-search {} :patient-search {} ...}? I
 understand that this isn't inefficient as components receive a cursor into
 their bit of the map thus avoiding unnecessary false changes.
 
  The main app will have an expandable left panel containing the global
 menu. In dom-manipulation world I would add a collapsed or expanded CSS
 class which defined the appropriate widths etc. In om (or rather react)
 land this is still possible I think, but is it more idiomatic to store the
 expanded/collapsed flag in the application state thus causing the panel
 component to re-render, the panel component then switching on that
 expanded? flag? The central panel also needs to be resized in response
 to the expansion/collapse, thus both components need to be in-sync. How is
 this idiomatically handled?
 
  In the more general case, there are components that need to be
 shown/hidden (tabs, validation pop-up errors etc.). In dom-manipulation
 world I would set css classes to change style's visibility for example, is
 this idiomatically done through flags in the application state?
 
  I am stumped as to how routing navigation fits into something like om.
 Again, is it a case that the navigation handlers simply update the
 application state? (You can see a theme in my thinking here!)
 
  In terms of reagent is it true to say that it is a bit less opinionated
 about these things and where-as om has a very opinionated approach to
 front-end state management (happening to use om), reagent is a (very nice)
 wrapper to om? Not to trivialize reagent, but is is simply trying to
 introduce clojurescript to react?
 
  Is it also true to say that whilst om wants to manage the whole
 application, reagent allows you to think about disconnected bits of your
 app?
 
  FWIW - reagent appeals to my pragmatic need to get stuff done and it
 feels very un-opinionated and very lightweight. However, the more I read
 about om the more it jives with me. However, I am in the pattern of yeah,
 that is how I would solve that problem, I just can't quite connect the
 dots in the bigger picture.
 
  It is also worth saying that there are no losers here, I am sure I will
 be delighted using either om or reagent.
 
  I think that is sufficient for now - thanks for reading, and thanks even
 more for responding :).

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] working reference/example apps in cljs wanted for educational purposes

2014-10-23 Thread Gary Verhaegen
On Thursday, 23 October 2014, Michiel Borkent michielbork...@gmail.com
wrote:

 So, what I'm looking for is good out of the box working examples in:

 - Vanilla clojurescript
 - React based examples

 Preferable the examples should be
 - short and simple (not thousands of lines of code)
 - easy to understand for newcomers
 - easy to run (lein cljsbuild once, open index.html)
 - not dependent on too many third party libraries


For my first dive into Clojurescript, I have found the Quiescent ToDoMVC
very interesting and readable:

https://github.com/levand/todomvc/tree/gh-pages/architecture-examples/quiescent

I already had some experience with Clojure (and go, so core.async was not
too foreign, even though I had never used it yet) and had read the entire
React documentation, so maybe I was not exactly your typical newbie.

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] 2014 State of Clojure ClojureScript Survey ends Oct 17th

2014-10-19 Thread Gary Verhaegen
Yes, they do. Probably within two weeks from now, according to the original
announcement. No hard deadline though.

On Sunday, 19 October 2014, Yehonathan Sharvit vie...@gmail.com wrote:

 On Tuesday, 14 October 2014 16:21:13 UTC+3, Alex Miller  wrote:
  Just a reminder that this Friday is the last day to complete the 2014
 State of Clojure  ClojureScript surveys:
 
 
 
 http://blog.cognitect.com/blog/2014/10/3/2014-state-of-clojure-clojurescript-survey
 
 
 
  So far 1110 people have filled out the State of Clojure survey and 544
 people have filled out the State of ClojureScript. If you haven't filled
 out the surveys yet, we would love for your answers to be included. The raw
 data and some analysis will be posted next week.
 
 
  Alex

 Do you intend to publish the resutls?

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Ecmascript6 is a threat?

2014-10-19 Thread Gary Verhaegen
Not anymore than Java 8 to Clojure.

JavaScript is getting better, but it's still not a lisp and it's still not
using immutable values *by default*.

On Sunday, 19 October 2014, Yehonathan Sharvit vie...@gmail.com wrote:

 Do you guys think that Ecmascript6 is a threat to clojurescript?

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:;.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.


Re: [ClojureScript] Deleting and local state

2014-10-18 Thread Gary Verhaegen
This should make things clear:

http://facebook.github.io/react/docs/reconciliation.html

On Saturday, 18 October 2014, Daniel Kersten dkers...@gmail.com wrote:

 Can you provide a little more code? Specifically, the render function of
 the events parent. I assume you are doing something like (om/build-all
 event-component (:events factory))

 Is there a unique id in each event by any chance? Presumably what is
 happening is that react doesn't properly detect which event was actually
 removed - only that one of them was removed (I've seen this a few times...)
 so if you provide what React calls a key then it can use this to
 disambiguate and correctly render the list. For example:

 If your events look like this {:id 3 :other :data}

 Then you can do something like this:

 (om/build-all event-component all-events {*:key :id*})

 If you don't have a field in the event that can be used as a key (a
 number, string or keyword that is unique across all events), then you could
 try something like this instead:

 (map-indexed
   (fn [idx event]
 (build event-component event {*:react-key idx*}))
   all-events)

 https://github.com/swannodette/om/wiki/Documentation#build

 On 18 October 2014 14:33, Andreas Liljeqvist bon...@gmail.com
 javascript:_e(%7B%7D,'cvml','bon...@gmail.com'); wrote:

 I have a vector of events in my factory-row.

 An event can be selected by clicking on it:

 (merge {:onClick #(om/set-state! owner :selected true)}
 (when selected {:style {:background
 white}}))

 If it is selected it will display a white background.
 This works fine.

 Problem is when I delete an item.
 1. Select the first item on the row (turns white)
 2. Delete the first item on the row (item disappears but the second item
 turns white)

 (will-mount [_]
   (let [delete (om/get-state owner :delete)]
 (go (loop []
   (let [event (! delete)]
 (om/transact! factory :events
   (fn [xs] (vec (remove (partial = event)
 xs
 (recur))


 Why is local-state propagated to the next item in the list?

 Thanks

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


  --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript%2bunsubscr...@googlegroups.com');
 .
 To post to this group, send email to clojurescript@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojurescript@googlegroups.com');.
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
ClojureScript group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.