var changes = db.changes({
since: 'now',
live: true,
include_docs: true
}).on('change', function(change) {
// handle change
}).on('complete', function(info) {
// changes() was canceled
}).on('error', function (err) {
console.log(err);
});
--
You received this message because you are subscribed to the Google Groups "DukeScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dukescript+...@googlegroups.com.
Visit this group at http://groups.google.com/group/dukescript.
To view this discussion on the web visit https://groups.google.com/d/msgid/dukescript/84133891-df62-425d-b7b5-044d9a252dba%40googlegroups.com.
As can be seen, there is a special syntax (starting with @) to properly identify the right Java method to call on a Java object passed into the JavaScript interpreter. The syntax starts with a fully qualified name of the class, followed by :: and name of the method including signature of its parameters. In case of runnable, this is just () as the method has no parameters, but the signature can be more complicated. For example in case of following method@
JavaScriptBody
(args = {"id", "r"},javacall
= true, body = "\n" + " document.getElementById(id).onclick = function() {\n" + " r.@
java.lang.Runnable::run()();\n" + " };\n" + " ") public static native void onClick(String id, Runnable r);
static int compare(int i1, String s1, int i2, String s2)
it would be (ILjava/lang/String;ILjava/lang/String;) (btw. the return type is not included in the signature). The actual parameters then follows. The JavaScript call to such compare method would then look like:@
the.pkg.Clazz::compare(ILjava/lang/String;ILjava/lang/String;)(1, 'One', 2, 'Two');
This syntax gives enough flexibility, helps to properly select one of overloaded methods and follows the tradition of previous attempts to provide JavaScript to Java calling conventions.Please note that to turn the special Java callback syntax on, one needs to set the JavaScriptBody.javacall()
attribute to true.Editing hint: there is an associated annotation processor that checks the syntax and verifies the referenced class and method of the right signature exist. If they do not, the compilation fails. Thus don't despair seeing the syntax, you'll get early warnings when there is a typo.Type Signature | Java Type |
---|---|
Z | boolean |
B | byte |
C | char |
S | short |
I | int |
J | long |
F | float |
D | double |
L fully-qualified-class ; | fully-qualified-class |
[ type | type[] |
( arg-types ) ret-type | method type |
For example, the Java method:
has the following type signature:
To view this discussion on the web visit https://groups.google.com/d/msgid/dukescript/88196995-0891-4fa7-ba19-e2d7e5f90bf6%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "DukeScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dukescript/fn9ECjNk_gQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dukescript+...@googlegroups.com.
Visit this group at http://groups.google.com/group/dukescript.
To view this discussion on the web visit https://groups.google.com/d/msgid/dukescript/E38B4F64-2004-4FB1-9B3B-20C1C4949C5B%40googlemail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to dukescript+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/dukescript.
To view this discussion on the web visit https://groups.google.com/d/msgid/dukescript/88196995-0891-4fa7-ba19-e2d7e5f90bf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "DukeScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/dukescript/fn9ECjNk_gQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to dukescript+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/dukescript.