I'm not familiar enough with Node to talk about options for sharing code
with the browser and common APIs, but there are two options I can think of:

1. Use cljx and create custom rulesets and features for node and the
browser, e.g. #+cljs-node and #+cljs-browser, and write your code using
cljx transformations.

2. Use the new reader conditionals in 1.7 and extend them to allow for node
and browser environments. At the moment I don't think that this extension
is possible, so 1 might be your only option without hacking on the
ClojureScript compiler.
On Sun, 26 Apr 2015 at 8:44 pm ducky <rohit.aggar...@gmail.com> wrote:

> Hello,
> I am working on creating a library which interacts with a HTTP resource
> using Clojurescript. I want to have it work within a browser and node.js.
>
> Does anyone have experience or an example showing how to target them both
> using a single code base?
>
> The issue I have noticed that in the browser one can work with
> XMLHTTPRequest using goog.net.Xhrio or a clojurescript library like
> cljs-http. And in node.js, you are expected to work with the http module.
>
> An option I have is to use XMLHttpRequest implemented using node's APIs.
> And then I have a common base. But I still don't know to target both in the
> same codebase. Having something like `(def http (js/require "http"))` is
> likely to produce an error in the browser.
>
> So any practical help with this would be really appreciated. How to
> structure the code, builds, test etc.
>
> Thanks!
>
> ducky
>
> --
> 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.

Reply via email to