Re: [ClojureScript] I wrote down my complains on React.js and JavaScript side, any opinions?

2016-06-09 Thread Val Waeselynck
As a language, I really like JavaScript. Once you get past the few pitfalls and 
the weird syntax, you get a powerful language with a lot of potential. Being 
dynamic, (somewhat) functional, and data-oriented, makes it the mainstream 
language that is closest to Clojure IMHO.

Now, as an ecosystem, I think the Javascript community lacks some great 
qualities that the Clojure community has. The Clojure community is full of 
brilliant people taking the language in a direction based on solid and clear 
principles. This is why I think ClojureScript is currently ahead of JavaScript 
for web development - smart people, fewer distractions and high-quality libs 
leading to wonderful tools like Figwheel, Om and Devcards in a very short time. 

JavaScript has all the technical features required to achieve the same things 
as ClojureScript - just not the spirit :)

On Tuesday, 7 June 2016 07:33:01 UTC+2, Jiyin Yiyong  wrote:
> I have to write JavaScript in my work, and that's not as nice as in 
> ClojureScript.
> 
> 
> On Mon, Jun 6, 2016 at 9:39 PM Marcus Magnusson  wrote:
> You know, I think I've been able to appreciate JavaScript more since learning 
> Clojure, I think it's taught me to think and program in ways that are more 
> effective in JS. That being said, I'd choose ClojureScript over JS any day of 
> the week :)
> 
> 
> 
> --
> 
> 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/tdm4DjUu_0Y/unsubscribe.
> 
> To unsubscribe from this group and all its topics, send an email to 
> clojurescrip...@googlegroups.com.
> 
> To post to this group, send email to clojur...@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.


[ClojureScript] Re: We need Fexpr to gain runtime metaprogramming

2016-05-23 Thread Val Waeselynck
On Friday, 6 May 2016 12:10:38 UTC+2, Olek  wrote:
> Hi!
> 
> Because macros are evaluated at compile time (they are compiletime 
> metaprogramming) and can't be used in eval in ClojureScript we need the Fexpr 
> https://en.wikipedia.org/wiki/Fexpr to be able adapt new flow concepts. For 
> example it would be handy to write interpreter pattern just by calling eval 
> on data structures of clojure to buildfor example UI based on mo-boostrap 
> clojurescript library.
> 
> Maybe there is already lib for Clojure/Clojurescript which will allow to gain 
> such functionality like Fexpr. For me the easiest solution is to override let 
> to be able to specify delay objects which can be later consumed with 
> deref/force. Of course the let should be expressive and succinct enough to be 
> used seamless, for example:
> 
> (defn my-if [ condition ~lazy-on-success ~& optional-lazy-on-failure ]
> (if condition @lazy-on-failure ~@optional-lazy-on-failure ))
> 
> and the use could be:
> 
> (my-if (:some-condition some-request)
>(do (println "do-some-side-effect") (println "and here another one"))
>(println "the failure side effect"))
> 
> (my-if (:some-condition-2 some-request)
>  (println "only on suscess"))
> 
> This is actually the only thing which I miss for succinct coding though all 
> layers of JEE apps. Runtime (and reflective) metaprogramming is right now 
> nicely supported by Groovy and JRuby, why not to bring it to ClojureScript?

It's not clear to me what such runtime metaprogramming features would bring to 
the table? 

Seems to me that having first-class functions, and multimethods and protocols 
defined at runtime is quite enough, I'm not sure what we're missing here. I get 
that Groovy's runtime metaprogramming features can be useful, but they're 
addressing the issue that classes and methods are so desperately not dynamic.

Generally speaking, I believe one of the guidelines of Clojure's development 
has been not to add features unless their utility is proven - 'why not add ' 
is not going to be enough :). Coming from the Scala and Javascript worlds where 
the proliferation of features leads to tons of distractions and incompatible 
interfaces, I'm personally quite happy with this phiosophy :)

> 
> Thanks in advance,
> Olek

-- 
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] es7 vs core.async

2015-09-27 Thread Val Waeselynck
Adding my grain of salt:

Le mercredi 16 septembre 2015 22:42:19 UTC+2, Andrey Antukh a écrit :
> Hi!
> 
> 
> I think you are comparing apples with oranges. CSP and async/await can't be 
> compared directly. Async/await works with a promise (one value) abstraction 
> and csp works with channel abstraction (sequence).
> 
> 
> It seems is an anti-pattern use channels as promises because them does not 
> has the notion of error.

Actually, I like error management better with core.async than with Promises  / 
Monads, because with little effort you can use the same error constructs for 
synchronous and asynchronous code: 
https://gist.github.com/alvalval/f1250cec76d3719a8343

I do agree that promises are a more natural fit for RPC systems, because of 
their signal-like nature. I feel I can't really avoid RPC for building web 
apps, I'd be glad to know about other strategies.


 I remember that Timothy Baldridge have said something similar about this:
> 
> 
> "A sort of anti-pattern I see a lot is creating a lot of one-shot channels 
> and go blocks inside every function. The problem, as you see is that this 
> creates a lot of garbage. A much more efficient plan is to stop using 
> core.async as a RPC-like system, and start using it more like a dataflow 
> language: Identity data sources and sinks, and then transform and flow the 
> data between them via core.async. 
> It's interesting to note that core.async started as something that looked a 
> lot like C#'s Async/Await, but that was dropped in favor of CSP pretty 
> quickly. So there's reasons why the language isn't optimized for this sort of 
> programming style. "
> 
> 
> Source: https://groups.google.com/d/msg/clojure/57ig0si3gUM/vRr-T1IaebUJ
> 
> 
> 
> Without the intention to make spam, the funcool/cats 
> (https://github.com/funcool/cats) `mlet`  macro does something similar in 
> semantics that async/await does. It there some examples using the ES6/7 
> compatible promise library: 
> http://funcool.github.io/promesa/latest/#sugar-syntax
> 
> 
> The advantage about this solution is that is generic and can be extended to 
> other async related abstractions as:
> - JDK8 CompletableFuture's 
> (https://github.com/funcool/promissum/blob/master/doc/content.adoc#26-promise-chaining)
>  
> - manifold deferred 
> (https://github.com/funcool/cats/blob/master/doc/content.adoc#82-manifold-deferred)
> - core.async channels 
> (https://github.com/funcool/cats/blob/master/doc/content.adoc#81-channel)
> 
> 
> Personally, I use core.async to compose different processes, but when I 
> interacting with async apis I almost always use promise abstraction with cats 
> sugar syntax. The promise abstraction semantics fits more properly in async 
> rpc calls that channels because it represents a "eventually available value" 
> and has the notion of error (unlikely core.async channels). 
> 
> 
> Regards.
> Andrey
> 
> 
> On Wed, Sep 16, 2015 at 10:30 PM, Marc Fawzi  wrote:
> 
> 
> 
> 
> Thanks for that!
> 
> async function baz() {
>   await* [foo(), bar()];
> }
> (defn baz []
>   (go
> (doseq [c [(foo) (bar)]]
>   ( right? It looks cryptic compared to the es7 version. Like "go" what does go 
> mean, seriously? I mean in terms of its English language context. Go does not 
> convey async. And what the heck is  kind of inverted redirection? I guess you can have macros that would make it 
> look just as comprehensible as the es7 async version so people coming into 
> CLJS won't be turned off by the crazy looking syntax and the exposed low 
> level semantics. Maybe a bunch of core.async macros that expose common use 
> cases in a way that anyone can understand without even having to understand 
> CSP basics. In my team, everyone gets the es7 version of things but despite 
> having been CLJS users for 6 months now, no one understands how to use 
> core.async. I've had to play with it in different languages before I realized 
> how powerful it is to have in your toolset to manage complex (potentially 
> dynamic) coordination patterns between async processes but our use cases in 
> the UI have yet to beyond the very simple use cases your gist shows which are 
> (without use of macros) much easier to understand using es7 async 
> functions.If macros can solve the "comprehensibility" problem for the common 
> use cases then maybe something that would provide es7 async like library for 
> cljs that gives you defnasync and await Syntax and semantics can then be so 
> simple while the underlying system remains so powerful and in that case you 
> could have core.async be bundled with those macros thus allowing easy access 
> to common async patterns without the Go syntax obfuscating things and making 
> it seem complicated as well as too noisy syntax wise for the most common 
> tasks 
> 
> Sent from my iPhone
> 
> 
> 
> On Sep 15, 2015, at 9:38 PM, Shaun LeBron  wrote:
> 
> 
> ES7 vs core.async (gist):
> https://gist.github.com/shaunlebron/d231431b4d6a82d83628
> 
> On Tuesday, S

[ClojureScript] ClojureScript FAQ for JS developers added to the Wiki

2015-09-26 Thread Val Waeselynck
As discussed in the Slack channel a few weeks ago, I've been working on a FAQ 
page for JavaScript programmers.

I added it to the ClojureScript Wiki, and it will probably make its way into 
cljs.info : 

https://github.com/clojure/clojurescript/wiki/FAQ-%28for-JavaScript-developers%29

Of course, criticism and contributions are welcome.

Cheers, 

Val

-- 
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] Re: Redirect in a SPA on the server side.

2015-09-12 Thread Val Waeselynck
Le samedi 12 septembre 2015 20:56:30 UTC+2, Hari Krishnan a écrit :
> On Saturday, September 12, 2015 at 6:19:41 AM UTC-7, Val Waeselynck wrote:
> > Because you're working with AJAX, you do not want your server to redirect. 
> > You want to just send the data to the server, and then change the URL of 
> > the page with something like 
> > 
> > window.location.href = 
> > 
> > Le samedi 12 septembre 2015 05:34:58 UTC+2, Hari Krishnan a écrit :
> > > Hello All,
> > > 
> > > 
> > > I am working on a use case as follows:  The UI is with reagent, re-frame 
> > > for subscription & Luminus, and for the backend, I use Compojure.  I also 
> > > tried with Liberator, but for simplicity, I am using only Compojure now.
> > > 
> > > I also use Secretary & cljs-ajax for SPA routing and ajax.
> > > 
> > > -> User brings up "/person"  URL, and use a set of actions.  The page 
> > > data is sent to the backend, gets validated and saved to the DB.  Then 
> > > the user has to be re-directed to "/job".  If there is any error, the 
> > > errors will be displayed on the "/person"  page.
> > > 
> > > There are two application components -- one with the URL "/person",and 
> > > the other with "/job".  With each of these, I have a few related pages, 
> > > and I am creating them as SPA with Reagent.
> > > 
> > > The question is how do I redirect to the "/job"?
> > > 
> > > Client Side Code (only the the relevant ones)
> > > 
> > > (POST "/person"
> > >   {:headers {"Accept" "application/clojure"}
> > >:params @doc
> > > 
> > >:handler ex-handler
> > >:error-handler ex-error-handler})
> > > 
> > > Server:
> > > (defn process-person []
> > >   (-> (redirect "/job" :permanent)
> > >   (header "Content-Type"  "text/html; charset=utf-8")
> > >   (header "Location"  "/job")
> > >   )
> > >   )
> > > 
> > > (POST "/person" [params] (process-person params))
> > > 
> > > Interestingly, on the console, I can see the HTML for the "job" page.  Do 
> > > I have to change the Secretary code to make it happen?
> > > 
> > > Any help is much appreciated.
> > > 
> > > Regards,
> > > Hari
> 
> Hi Val,
> 
> Thanks for the answer.  I still have one more issue related to this logic.  
> When I set the :location at the header onn the server side, what I see on the 
> client console (Chrome) is as follows (logging the response from the server): 
>  I don't see the location key/value, instead, I see the whole page in HTML.  
> Any hint?  tried with different doc-types.
> 
> {:status 200, 
>   :success true, 
>   :body "\r\n\r\n\r\n\r\n  \r\n  \r\n  
> --\r\n", 
> 
> :headers {"date" "Sat, 12 Sep 2015 18:27:30 GMT", "x-content-type-options" 
> "nosniff", "server" "undertow", "x-frame-options" "SAMEORIGIN", 
> "content-type" "text/html; charset=utf-8", "connection" "keep-alive", 
> "content-length" "3928", "x-xss-protection" "1; mode=block"}, 
> :trace-redirects ["/person" "/person"], 
> :error-code :no-error, 
> :error-text ""}
> 
> (defresource post-person-resource
>  :available-media-types [ "application/clojure"]
>  :allowed-methods [:post]
>  :post! (fn [context] ())
>  :post-redirect? (fn [ctx] {:location "/job"})
> 
> ON THE Client side, I solved the redirect issue with the following code:
> 
> (.assign js/location "/job")
> 
> But I couln't find the location in the header.  So I hard-coded it here!
> 
> Thanks for the response.
> 
> Regards,
> Hari

This is how HTTP works. What you're seeing is the "target" response of the 
redirection, not the "redirect" response (which has a 301 status code and a 
"Location" header).

Again, this weird hybridation of classical web pages / AJAX behavior is 
probably the root of all evil here :). IMO the way to go here is to not 
redirect from the server, this is a decision to be made by the client (and your 
client knowing why it fetched the data, it probably also knows where to go next 
:) ).

-- 
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] Re: Redirect in a SPA on the server side.

2015-09-12 Thread Val Waeselynck
Because you're working with AJAX, you do not want your server to redirect. You 
want to just send the data to the server, and then change the URL of the page 
with something like 

window.location.href = 

Le samedi 12 septembre 2015 05:34:58 UTC+2, Hari Krishnan a écrit :
> Hello All,
> 
> 
> I am working on a use case as follows:  The UI is with reagent, re-frame for 
> subscription & Luminus, and for the backend, I use Compojure.  I also tried 
> with Liberator, but for simplicity, I am using only Compojure now.
> 
> I also use Secretary & cljs-ajax for SPA routing and ajax.
> 
> -> User brings up "/person"  URL, and use a set of actions.  The page data is 
> sent to the backend, gets validated and saved to the DB.  Then the user has 
> to be re-directed to "/job".  If there is any error, the errors will be 
> displayed on the "/person"  page.
> 
> There are two application components -- one with the URL "/person",and the 
> other with "/job".  With each of these, I have a few related pages, and I am 
> creating them as SPA with Reagent.
> 
> The question is how do I redirect to the "/job"?
> 
> Client Side Code (only the the relevant ones)
> 
> (POST "/person"
>   {:headers {"Accept" "application/clojure"}
>:params @doc
> 
>:handler ex-handler
>:error-handler ex-error-handler})
> 
> Server:
> (defn process-person []
>   (-> (redirect "/job" :permanent)
>   (header "Content-Type"  "text/html; charset=utf-8")
>   (header "Location"  "/job")
>   )
>   )
> 
> (POST "/person" [params] (process-person params))
> 
> Interestingly, on the console, I can see the HTML for the "job" page.  Do I 
> have to change the Secretary code to make it happen?
> 
> Any help is much appreciated.
> 
> Regards,
> Hari

-- 
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] New ClojureScript tutorial based on AngularJS official Phonecat tutorial

2015-09-05 Thread Val Waeselynck
A few months ago, I ported the code of the official AngularJS tutorial to 
ClojureScript + Reagent, and put it in a repository with diffs side by side.

I'm now pleased to annouce that I've actually ported the tutorial itself as 
well, which guides you step by step through building the application, with 
detailed explanation.

See it here: https://github.com/alvalval/reagent-phonecat-tutorial/wiki

I hope this will be a valuable resource for ClojureScript beginners. 

I did this on my own, so criticism and suggestion for improvement are very 
welcome.

Cheers!

-- 
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] Re: Études for ClojureScript: Chapter 8 review, please?

2015-08-14 Thread Val Waeselynck
Ah OK.

I don't know what you mean by "reasonable", it depends on the teaching 
objective, but the 2 examples which are already there seem good to me.

One thing I've noticed: in the first example you're writing something like 
(loop [_ nil] ... (recur nil))

You could just write (loop [] ... (recur)) . 

Le vendredi 14 août 2015 15:22:49 UTC+2, J David Eisenberg a écrit :
> On Friday, August 14, 2015 at 2:57:46 AM UTC-7, Val Waeselynck wrote:
> > Le vendredi 14 août 2015 05:53:11 UTC+2, J David Eisenberg a écrit :
> > > I have written the introduction to Chapter 8 (Asynchronous processes), 
> > > but I am not sure if the example programs are reasonable. The examples 
> > > will lead into an étude to implement the card game "war" with the 
> > > computer playing against itself via asynchronous processes.
> > > 
> > > I would appreciate it if you-all could take a look at it and make 
> > > suggestions or comments. (I'm not confident I'm anywhere near on the 
> > > right track, so I'm OK with feedback like "OMG WTF LOL")
> > > 
> > > Link is http://catcode.com/etudes-for-clojurescript/
> > 
> > In the code examples I see the >!  
> I'm using O'Reilly's atlas system to do the build, and there appears to be a 
> problem with the build system; it's OK in the ePub and PDF versions. I've 
> filed a bug report; thanks.

Ah OK. Well I'll try the

-- 
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] Re: Études for ClojureScript: Chapter 8 review, please?

2015-08-14 Thread Val Waeselynck
Le vendredi 14 août 2015 05:53:11 UTC+2, J David Eisenberg a écrit :
> I have written the introduction to Chapter 8 (Asynchronous processes), but I 
> am not sure if the example programs are reasonable. The examples will lead 
> into an étude to implement the card game "war" with the computer playing 
> against itself via asynchronous processes.
> 
> I would appreciate it if you-all could take a look at it and make suggestions 
> or comments. (I'm not confident I'm anywhere near on the right track, so I'm 
> OK with feedback like "OMG WTF LOL")
> 
> Link is http://catcode.com/etudes-for-clojurescript/

In the code examples I see the >! http://groups.google.com/group/clojurescript.


[ClojureScript] 'Pluggable' React (Reagent) components

2015-08-12 Thread Val Waeselynck
I've been experimenting lately with the concept of 'pluggable' components.

In a nutshell, it's a tiny API that lets you write stateful components with a 
heavy lifecycle in a declarative way, without the tedium of explicitely writing 
React lifecycle methods.

https://github.com/alvalval/reagent-pluggable-components-poc/blob/master/README.md

I would know what people think, it they consider it good design and if they've 
ever felt a need for it. Feedback welcome!

Cheers,

Val

-- 
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: Trying to compile calls to new google analytics API fails with advanced compilation

2015-06-07 Thread Val Waeselynck
I did try that initially, I wrote the following ga.ext.js file:

var ga = function(){};

It did not work, the name got munged. That's why I used another approach after.

This may be my build process that's broken, but that would surprise me, since I 
did manage to write an extern file for the Facebook SDK.



Le dimanche 7 juin 2015 15:14:26 UTC+2, Daniel Kersten a écrit :
> How about writing an extern for the ga function? Presumably the closure 
> compiler will prevent name clashes then?
> 
> 
> On Sun, 7 Jun 2015 13:59 Val Waeselynck  wrote:
> Alright, I managed to get it to work.
> 
> 
> 
> I'm not expert enough in Closure to understand why, but what made it work for 
> me was that the function was local-bound, i.e the following didn't work:
> 
> 
> 
> (def ga (aget js/window "ga"))
> 
> ;; ... and later in the code
> 
>     (ga "create" my-account-id "auto")
> 
> 
> 
> However, the following did work:
> 
> 
> 
> (defn ga [& args]
> 
>   (let [g (aget js/window "ga")]
> 
>     (apply g args)))
> 
> ;; ... and later in the code
> 
>     (ga "create" my-account-id "auto")
> 
> 
> 
> 
> 
> 
> 
> Le dimanche 7 juin 2015 14:47:43 UTC+2, Val Waeselynck a écrit :
> 
> > Le jeudi 17 juillet 2014 09:36:02 UTC+2, Thomas Heller a écrit :
> 
> > > Hey,
> 
> > >
> 
> > > the problem is not that closure munges the window.ga function, it is that 
> > > closure creates a var named ga which can be anything but is not the 
> > > analytics ga. At least it was in my case.
> 
> > >
> 
> > > My solution was to use the renaming feature of the analytics snippet to 
> > > use a name closure won't generate and then call it using aget.
> 
> > >
> 
> > > Example:
> 
> > >
> 
> > > Last part of the analytics snippet:
> 
> > > (window, document, 'script', '//www.google-analytics.com/analytics.js', 
> > > '$MY_GA');
> 
> > >
> 
> > > Then to call analytics:
> 
> > >
> 
> > > (let [ga (aget js/window "$MY_GA")]
> 
> > >   (ga "create" analytics-account-id "auto"))
> 
> > >
> 
> > > That fixed everything for me.
> 
> > >
> 
> > > HTH,
> 
> > > /thomas
> 
> > >
> 
> > > On Thursday, July 17, 2014 6:33:28 AM UTC+2, tal giat wrote:
> 
> > > > Hi,
> 
> > > >
> 
> > > > We have clojurescript code calling the google analytics api that is 
> > > > created on a regular html page with the usual embed code, like this:
> 
> > > >
> 
> > > > (function (i, s, o, g, r, a, m) {
> 
> > > >         i['GoogleAnalyticsObject'] = r;
> 
> > > >         i[r] = i[r] || function () {
> 
> > > >             (i[r].q = i[r].q || []).push(arguments)
> 
> > > >         };
> 
> > > >         i[r].l = 1 * new Date();
> 
> > > >         a = s.createElement(o),
> 
> > > >         m = s.getElementsByTagName(o)[0];
> 
> > > >         a.async = 1;
> 
> > > >         a.src = g;
> 
> > > >         m.parentNode.insertBefore(a, m)
> 
> > > >       })(window, document, 'script', 
> > > >'//www.google-analytics.com/analytics.js', 'ga');
> 
> > > >
> 
> > > > In a clojurescript file we have function to report pageviews like that:
> 
> > > >
> 
> > > > (defnk init-analytics [analytics-account-id user-id account-id]
> 
> > > >   (.ga js/window "create" analytics-account-id "auto")
> 
> > > >   (.ga js/window "set" "&uid" (str user-id))
> 
> > > >   (.ga js/window "set" "dimension1" (str user-id))
> 
> > > >   (.ga js/window "set" "dimension2" (str account-id))
> 
> > > >   (.ga js/window "send" "pageview" (get-page)))
> 
> > > >
> 
> > > > This works fine without the advanced compilation mode but fails on 
> > > > advanced one. This code is being compiled to a munged name, in this 
> > > > case window.nc instead of window.ga
> 
> > > >
> 
> > > > I've tried to add to our extens file (we have other external libraries 
> > > > that work fine) the follwoing:
> 
> &

[ClojureScript] Re: Trying to compile calls to new google analytics API fails with advanced compilation

2015-06-07 Thread Val Waeselynck
Alright, I managed to get it to work.

I'm not expert enough in Closure to understand why, but what made it work for 
me was that the function was local-bound, i.e the following didn't work:

(def ga (aget js/window "ga"))
;; ... and later in the code
(ga "create" my-account-id "auto")

However, the following did work:

(defn ga [& args]
  (let [g (aget js/window "ga")]
(apply g args)))
;; ... and later in the code
(ga "create" my-account-id "auto")



Le dimanche 7 juin 2015 14:47:43 UTC+2, Val Waeselynck a écrit :
> Le jeudi 17 juillet 2014 09:36:02 UTC+2, Thomas Heller a écrit :
> > Hey,
> > 
> > the problem is not that closure munges the window.ga function, it is that 
> > closure creates a var named ga which can be anything but is not the 
> > analytics ga. At least it was in my case.
> > 
> > My solution was to use the renaming feature of the analytics snippet to use 
> > a name closure won't generate and then call it using aget.
> > 
> > Example:
> > 
> > Last part of the analytics snippet:
> > (window, document, 'script', '//www.google-analytics.com/analytics.js', 
> > '$MY_GA');
> > 
> > Then to call analytics:
> > 
> > (let [ga (aget js/window "$MY_GA")]
> >   (ga "create" analytics-account-id "auto"))
> > 
> > That fixed everything for me.
> > 
> > HTH,
> > /thomas
> > 
> > On Thursday, July 17, 2014 6:33:28 AM UTC+2, tal giat wrote:
> > > Hi,
> > > 
> > > We have clojurescript code calling the google analytics api that is 
> > > created on a regular html page with the usual embed code, like this:
> > > 
> > > (function (i, s, o, g, r, a, m) {
> > > i['GoogleAnalyticsObject'] = r;
> > > i[r] = i[r] || function () {
> > > (i[r].q = i[r].q || []).push(arguments)
> > > };
> > > i[r].l = 1 * new Date();
> > > a = s.createElement(o),
> > > m = s.getElementsByTagName(o)[0];
> > > a.async = 1;
> > > a.src = g;
> > > m.parentNode.insertBefore(a, m)
> > >   })(window, document, 'script', 
> > > '//www.google-analytics.com/analytics.js', 'ga');
> > > 
> > > In a clojurescript file we have function to report pageviews like that:
> > > 
> > > (defnk init-analytics [analytics-account-id user-id account-id]
> > >   (.ga js/window "create" analytics-account-id "auto")
> > >   (.ga js/window "set" "&uid" (str user-id))
> > >   (.ga js/window "set" "dimension1" (str user-id))
> > >   (.ga js/window "set" "dimension2" (str account-id))
> > >   (.ga js/window "send" "pageview" (get-page)))
> > > 
> > > This works fine without the advanced compilation mode but fails on 
> > > advanced one. This code is being compiled to a munged name, in this case 
> > > window.nc instead of window.ga
> > > 
> > > I've tried to add to our extens file (we have other external libraries 
> > > that work fine) the follwoing:
> > > var ga = function(args); but that doesn't help. 
> > > 
> > > The closure compiler has externs for the analytics api but that seems 
> > > like an old one (old analytics API that is):
> > > 
> > > https://github.com/google/closure-compiler/blob/master/contrib/externs/google_analytics_api.js
> > > 
> > > Does someone ran into similar problem and can post a solution 
> > > 
> > > Thanks
> 
> Didn't work for me :/

-- 
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] Re: Trying to compile calls to new google analytics API fails with advanced compilation

2015-06-07 Thread Val Waeselynck
Le jeudi 17 juillet 2014 09:36:02 UTC+2, Thomas Heller a écrit :
> Hey,
> 
> the problem is not that closure munges the window.ga function, it is that 
> closure creates a var named ga which can be anything but is not the analytics 
> ga. At least it was in my case.
> 
> My solution was to use the renaming feature of the analytics snippet to use a 
> name closure won't generate and then call it using aget.
> 
> Example:
> 
> Last part of the analytics snippet:
> (window, document, 'script', '//www.google-analytics.com/analytics.js', 
> '$MY_GA');
> 
> Then to call analytics:
> 
> (let [ga (aget js/window "$MY_GA")]
>   (ga "create" analytics-account-id "auto"))
> 
> That fixed everything for me.
> 
> HTH,
> /thomas
> 
> On Thursday, July 17, 2014 6:33:28 AM UTC+2, tal giat wrote:
> > Hi,
> > 
> > We have clojurescript code calling the google analytics api that is created 
> > on a regular html page with the usual embed code, like this:
> > 
> > (function (i, s, o, g, r, a, m) {
> > i['GoogleAnalyticsObject'] = r;
> > i[r] = i[r] || function () {
> > (i[r].q = i[r].q || []).push(arguments)
> > };
> > i[r].l = 1 * new Date();
> > a = s.createElement(o),
> > m = s.getElementsByTagName(o)[0];
> > a.async = 1;
> > a.src = g;
> > m.parentNode.insertBefore(a, m)
> >   })(window, document, 'script', 
> > '//www.google-analytics.com/analytics.js', 'ga');
> > 
> > In a clojurescript file we have function to report pageviews like that:
> > 
> > (defnk init-analytics [analytics-account-id user-id account-id]
> >   (.ga js/window "create" analytics-account-id "auto")
> >   (.ga js/window "set" "&uid" (str user-id))
> >   (.ga js/window "set" "dimension1" (str user-id))
> >   (.ga js/window "set" "dimension2" (str account-id))
> >   (.ga js/window "send" "pageview" (get-page)))
> > 
> > This works fine without the advanced compilation mode but fails on advanced 
> > one. This code is being compiled to a munged name, in this case window.nc 
> > instead of window.ga
> > 
> > I've tried to add to our extens file (we have other external libraries that 
> > work fine) the follwoing:
> > var ga = function(args); but that doesn't help. 
> > 
> > The closure compiler has externs for the analytics api but that seems like 
> > an old one (old analytics API that is):
> > 
> > https://github.com/google/closure-compiler/blob/master/contrib/externs/google_analytics_api.js
> > 
> > Does someone ran into similar problem and can post a solution 
> > 
> > Thanks

Didn't work for me :/

-- 
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] Re: PowerCursors! ;)

2015-05-25 Thread Val Waeselynck
I have been looking for exactly that, thanks!

Le vendredi 8 mai 2015 00:52:45 UTC+2, Frozenlock a écrit :
>
> You might be interested in a quick look at:
> https://github.com/Frozenlock/entanglement
>
> I wrote it after working on reagent-cursors and seeing a pattern emerge.
>
> The main purpose is to have an abstraction layer between the data and the 
> application (IE Reagent).
> This way you can decouple how Reagent is written and how your data is 
> stored in an atom.
>
> (Related Reagent issue: 
> https://github.com/reagent-project/reagent/issues/92)
>
>
> On Tuesday, May 5, 2015 at 7:47:02 PM UTC-4, marc fawzi wrote:
>>
>> So after a couple of months drooling over ClojureScript's more advanced 
>> facilities, I've finally managed to play with Protocols and Records. 
>>
>> It feels a bit OO-ish me, but can't see how I could survive without it
>>
>> Is this really functional programming or did I subconsciously revert to 
>> OO? 
>>
>> PowerCursors >>> 
>>
>> https://gist.github.com/idibidiart/0090a95b6b4f9c12c070
>>
>>
>> The previous version was a weaker abstraction which used multi-methods (
>> https://gist.github.com/idibidiart/2b3aa1594ce707227b96) and is very 
>> amateur in retrospect so I'm hoping the next version will be that much 
>> better... 
>>
>> This one doesn't even 
>>
>> If you have any feedback for this n00b please don't hesitate to share 
>> here.
>>
>> Btw, all of this digging and exploring because of one comment at our last 
>> SF Reagent meetup that cursors were just simple pointers. The latest 
>> abstraction doesn't even use any cursor per se but invents it's own simple 
>> yet more robust lensing pattern.
>>
>> Thank you for all your help answering my often ridiculous questions.
>>
>> Marc
>> p.s. the last meetup's video IS coming this Thursday, and it will put all 
>> of this "Cursors can do it all, depending on how you define them"  in 
>> context.. 
>>
>>

-- 
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] Reagent port of the Om tutorial

2015-02-11 Thread Val Waeselynck
Le samedi 25 janvier 2014 15:57:16 UTC+1, Moritz Ulrich a écrit :
> Jonas Enlund writes:
> 
> > On Saturday, January 25, 2014 9:49:56 AM UTC+2, David Nolen wrote:
> >> Nice. I do consider the non-modularity of `update-contacts!` here to be 
> >> one of the big things I try to address in Om. The Reagent 
> >> `update-contacts!` knows too much. In Om, it doesn't matter at all where 
> >> :contacts lives in the app state, the Om contacts-view can still update it.
> >
> > So if I understand correctly the 'app' arg in (defn contacts-view [app 
> > owner] ...) doesn't have to be the root of the app-state atom?
> 
> You understand correctly. Om implements a cursor data-structure which
> allows you to pass a 'subset' (for example (:contacts state) of the
> components. om/update! will update as expected (it will just see the
> :contacts part of the state).

If I may, Reagent has cursors too: 
https://github.com/reagent-project/reagent-cursor, that allow exactly 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.