[ClojureScript] Re: Exporting UMD from ClojureScript library

2015-11-22 Thread Shaun LeBron
Thanks, Thomas!  will post result here when completed.

On Sunday, November 22, 2015 at 3:20:49 AM UTC-6, Thomas Heller wrote:
> Hey,
> 
> my advice would be to use a post-process step instead of trying to making it 
> go through the closure compiler. Not only will that produce headaches but the 
> generated CLJS->JS also does not match the expected structure for UMD exports.
> 
> You'd need to tag the functions you want to have available by name ala
> 
> (defn ^:export js-indent-mode []...)
> 
> and then refer to them on the exports. Note that you need to refer to the 
> munged names (eg. _ instead of -).
> 
> I do not know how to do this in cljsbuild but could show you an example in 
> shadow-build if interested. Anyways all you'd need is to pipe the  compiled 
> output into the below script (at the marker). No externs needed for this case.
> 
> (function (root, factory) {
> if (typeof define === 'function' && define.amd) {
> // AMD. Register as an anonymous module.
> define([], factory);
> } else if (typeof module === 'object' && module.exports) {
> // Node. Does not work with strict CommonJS, but
> // only CommonJS-like environments that support module.exports,
> // like Node.
> module.exports = factory();
> } else {
> // Browser globals (root is window)
> root.returnExports = factory();
>   }
> }(this, function () {
> 
> // CLJS-COMPILED-OUTPUT-HERE
>   
> return {indentMode: parinfer.api_js.js_indent_mode,
> indentModeChange: parinfer.api_js.js_indent_mode_change,
> parenMode: parinfer.api_js.js_paren_mode};
> }));
> 
> 
> HTH,
> /thomas
> 
> On Sunday, November 22, 2015 at 8:42:53 AM UTC+1, Shaun LeBron wrote:
> > I'm trying to export a JavaScript API from my ClojureScript library using a 
> > UMD pattern, given the following export function:
> > https://github.com/shaunlebron/parinfer/blob/7131d10ee21a6674279577b76743f623d4b2c3c9/parinfer-lib/src/parinfer/api_js.cljs#L64-L70
> > 
> > After compiling in advanced mode, and running Node, 
> > `require("./parinfer.js")` just returns {}.  Adding the `:target :nodejs` 
> > option doesn't help.
> > 
> > I'm thinking it has something to do with google closure renaming my 
> > `module` symbol despite having the externs to prevent it.  Anyway to 
> > prevent this?

-- 
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: ANN: DataScript, in-memory database and datalog queries in ClojureScript

2015-11-22 Thread Nikita Prokopov
On Tuesday, October 27, 2015 at 4:05:04 PM UTC+6, Scott Klarenbach wrote:
> On Thursday, April 24, 2014 at 11:18:06 PM UTC-7, Nikita Prokopov wrote:
> > Hi!
> > 
> > I’m glad to announce my new library, DataScript.
> > 
> > It’s an open-source, from-the-scratch implementation of in-memory immutable 
> > database aimed at ClojureScript with API and data model designed after 
> > Datomic. Full-featured Datalog queries included.
> > 
> > Library is here: https://github.com/tonsky/datascript
> > 
> > Also check out this blog post about why you may need a database in a 
> > browser: http://tonsky.me/blog/decomposing-web-app-development/
> > 
> > Feedback welcome!
> 
> Hello,
> 
> Very helpful library Nikita.
> 
> I wonder what would be required to enable datascript to act more like a 
> datomic peer, which holds, say, part of the db in browser memory, and then 
> goes back to the server to fetch new segments if it can't serve the query 
> from browser cache.  Older entries in the cache get gc'd and the system can 
> operate on dbs of any size.
> 
> I realize this wasn't a design goal of datascript, and am just looking for 
> insights into how it might be possible.  I guess a more fundamental question 
> is: how does a datomic peer know when the segments to complete its query are 
> not present in cache?  And can we emulate this in datascript?

Requesting segments on-demand is, in theory, possible. DataScript is written to 
support queries over data source protocol, which can be a DB (we can then 
utilize indexes), collection (full scans) or something user-specific. I don’t 
have working example of that at the moment, but from design perspective, 
plugging in custom data source with, e.g., on-demand segment loader, is 
possible.

-- 
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: ANN: DataScript, in-memory database and datalog queries in ClojureScript

2015-11-22 Thread Nikita Prokopov
On Tuesday, October 27, 2015 at 9:39:00 PM UTC+6, kovas boguta wrote:
> Checking in with Datascript and impressed with the progress. Very cool
> that its cljc now.
> 
> I'd love to see Datascript being able to query large static datasets.
> In general Datascript is interesting for doing the things Datomic
> doesnt do.
> 
> Forget all the transactor/coordination/live-merge stuff. Lets assume I
> just map-reduced some dataset into various datom indices, and now I
> want to query it. Wikidata comes to mind for me.
> 
> Looking at the code, it looks like there is some pluggability wrt the
> source of datoms, so it seems doable for someone who knows the
> codebase ;)
> 
> I've definitely encountered a number of other people with this use
> case. Love datomic datalog, love navigation, love direct data access,
> don't love the 10 billion datom limit and dont need transactions.
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On Tue, Oct 27, 2015 at 7:40 AM, Robin Heggelund Hansen
>  wrote:
> > One thing to keep in mind is that a datomic peer retrieves "the index" when 
> > it first connects to a transactor. The peer can use this to get a picture 
> > of what is available, and thus what it can retrieve when running queries. 
> > Another thing to keep in mind is that a datomic peer receives every change 
> > from the transactor, so that it is always up to date.
> >
> > Browsers don't need access to the entire database, just the relevant data 
> > for a particular client. What you can do is to connect to the backend using 
> > websockets. When you first connect, you ask for all relevant data for this 
> > particular user. After that, the backend can push updates for this 
> > particular user, to keep the client up to date.
> >
> > --
> > 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.

In theory, yes, queries should work on any dataset provided it implements some 
basic protocol. In practice, I have to build an example of that to see what 
pieces are missing at the moment.

-- 
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: Exporting UMD from ClojureScript library

2015-11-22 Thread Thomas Heller
Hey,

my advice would be to use a post-process step instead of trying to making it go 
through the closure compiler. Not only will that produce headaches but the 
generated CLJS->JS also does not match the expected structure for UMD exports.

You'd need to tag the functions you want to have available by name ala

(defn ^:export js-indent-mode []...)

and then refer to them on the exports. Note that you need to refer to the 
munged names (eg. _ instead of -).

I do not know how to do this in cljsbuild but could show you an example in 
shadow-build if interested. Anyways all you'd need is to pipe the  compiled 
output into the below script (at the marker). No externs needed for this case.

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], factory);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.returnExports = factory();
  }
}(this, function () {

// CLJS-COMPILED-OUTPUT-HERE

return {indentMode: parinfer.api_js.js_indent_mode,
indentModeChange: parinfer.api_js.js_indent_mode_change,
parenMode: parinfer.api_js.js_paren_mode};
}));


HTH,
/thomas

On Sunday, November 22, 2015 at 8:42:53 AM UTC+1, Shaun LeBron wrote:
> I'm trying to export a JavaScript API from my ClojureScript library using a 
> UMD pattern, given the following export function:
> https://github.com/shaunlebron/parinfer/blob/7131d10ee21a6674279577b76743f623d4b2c3c9/parinfer-lib/src/parinfer/api_js.cljs#L64-L70
> 
> After compiling in advanced mode, and running Node, 
> `require("./parinfer.js")` just returns {}.  Adding the `:target :nodejs` 
> option doesn't help.
> 
> I'm thinking it has something to do with google closure renaming my `module` 
> symbol despite having the externs to prevent it.  Anyway to prevent this?

-- 
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.