Are Mootools and Google Closure Librarys Compatible? - mootools

Anyone have any experience of using Closure js lib and Mootools in the same page?
Conflicts or works ok?

According to google:
The names of all Closure Library
functions and properties begin with a
dot-delimited path that prevents them
from accidentally overlapping with
names defined in non-Closure Library
code. This path is called a namespace.
(http://code.google.com/closure/library/docs/introduction.html)
So there should be no conflicts, also I checked the API documentation and it reaffirms my findings, for example, for array manipulation you have to go through the google namespace (goog):
goog.array.binaryInsert(array, value, opt_compareFn) ⇒
boolean
(http://closure-library.googlecode.com/svn/trunk/closure/goog/docs/closure_goog_array_array.js.html)
This is unlike the MooTools extention of the Array class itself.
Cheers,
Roman

Related

How can I add a namespace when I use XPath using $x function in Google Chrome?

I usually use $x() function on Google Chrome development console. However, when XML file has a namespace the query does not work. I could not find any way to add the namespace. I was wondering if I am missing something or is a missing feature.
I don't know if there is a way to include namespaces in the function, but it's possible to (try to) avoid them altogether by using local-name().
For example, if your element is (picked randomly for an EDGAR filing):
<edgar:companyName>Federal Bank of Boston</edgar:companyName>
This expression
$x('//*[local-name()="companyName"]')
should select it.

Use a different React version with clojurescript react libraries (reagent,om,rum,quiescent)

How can I use a different React version with Reagent, Om, Rum, Quiescent or Brutha?
Self answer since this is asked frequently:
First you have to tell Leiningen to exclude the cljsjs/react dependencies:
[rum "0.6.0" :exclusions [[cljsjs/react] [cljsjs/react-dom]]]
If you have other dependencies pulling in cljsjs/react you can use a global exclusion:
:exclusions [[cljsjs/react] [cljsjs/react-dom]]
Next you have to satisfy the compiler since it won't find the namespaces cljsjs.react and cljsjs.react.dom. For this create two files that hold these namespaces in your source directory. For instance
- src/cljsjs/react.cljs
- src/cljsjs/react/dom.cljs
Both only need the namespace declaration and can otherwise be empty (ns cljsjs.react).
Now you can include any React version you'd like manually in your HTML file with a normal <script> tag.
Alternative:
You can also use foreign-libs compiler option.

Is it possible to call a ClojureScript module from a jQuery or AngularJS normal webapp?

I have an existing web UI that I would like to be able to call a function written in ClojureScript. The function would be in a separate ClojureScript module (cs_func.js file) that does not need access to the DOM. I can't find any examples on how to do this.
Yes, this is possible (cf. how to use a complex return object from clojurescript in javascript… for instance). As you already figured out, ClojureScript will be compiled to normal JavaScript files (where "normal" varies according to your cljsbuild settings on how aggressive the output will be optimized). This is more a Javascript question on how to access the compiled JavaScript module than anything else.
You should be aware, however, that the output from cljsbuild might get mingled and that you probably want to prohibit this for your entrypoints, cf. the discussion in the section "Exporting ClojureScript functions" in this article on ClojureScript/JavaScript interop and the even more detailed discussion in Luke VanderHarts article on using JavaScript and ClojureScript

atom packages, clojurescript, google closure and dependency management

I'm writing some atom (the editor) package with ClojureScript. And i faced dependency load issue.
When compiled ClojureScript produces file like this (main.js):
goog.addDependency("base.js", ['goog'], []);
goog.addDependency("../cljs/core.js", ['cljs.core'], ...)
goog.addDependency("../clojure/browser/event.js", ...)
Obviously, ClojureScript heavily depends on Google Closure dependency management.
But, to be able to use Google Closure i need to include goog/base.js file.
The only way that i found is to add to goog/base.js:
module.exports = goog
and add to main.js:
require('./goog/base.js')
This is very bad approach, because these files are generated - so they can be overridden.
Also, release compilation will not include these lines.
The question is how can i use both these dependency systems?
Or is it possible to use ClojureScript w/o Google Closure?
Please advice, thanks!
If you set your ClojureScript :optimizations to something other than :none (e.g., :whitespace) then the resulting .js file will include the Google Closure code inlined and you won't have to reference it separately.
(Note that this means you might not be able to use a main function in your ClojureScript code, but you can just put a call to your main function somewhere at the toplevel.)

How to replace gwt json with my own json implementation

I need to find a method to work json implementation in my gwt-project com.google.gwt.json.client package instead of json in GWT com.google.gwt.json package.
In my GWT project I want to use json implementation written by myself and stored in a package in my project with same path as that of GWT json package.
Files inside this packages are com.google.gwt.json.client implemented by myself and keep in same package in my project, how to configure in project to use these packages instead of original.
Any suggestions regarding this will be appreciated.
Thanks to all..
UPDATES:
For more clarification on what I am looking for:
While parsing with JSONUtils in GWT, make parser to use JSONObject written in my project com.google.gwt.json package, insted of GWT-json in com.google.gwt.json package.
Sometimes it is necessary to modify certain GWT core classes because either, you need to fix an issue, or you need to add a new feature to them.
To override any GWT implementation class, for instance com.google.gwt.json.client.JSONObject, you only have to copy and modify that class in your src folder with the same path: src/main/java/com/google/gwt/json/client/JSONObject.java if you are using maven, src/com/google/gwt/json/client/JSONObject.java otherwise.
The only care you need is that your src folder is first in your classpath than the gwt sdk, with maven it is so by default. You should be aware as well that when you update the gwt version, perhaps you would need to update your implementations.
If the instances of the class you were trying to override, are created in GWT using the GWT.create() call, you could replace the class with your own implementation with a <replace-with> tag in your .gwt.xml. This technique is called deferred-binding. This is not the case since JSONObject is normally created with new.
Finally the <super-source> tag can be used to override any class implementation in compile time. Although super-source is designed to override jre classes by gwt implementations, replacing gwt with other gwt implementations works. In this case you have to put your modified classes, with the same namespace structure, in the folder pointed by the super-source tag.