(function (window, document, undefined) {
function WatchDog(name) {
this._name = name;
};
WatchDog.prototype.register = function(callback) {
this._callback = callback;
};
WatchDog.prototype.broadcast = function(msg) {
if (this._callback) {
this._callback({
'name' : this._name,
'timestamp' : new Date().getTime(),
'msg' : msg
});
}
};
window.Dummy = {
watchDog : function(name) {
return new WatchDog(name);
}
};
}(window, document));
package xxx;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class Dummy {
private Dummy() {}
public static native WatchDog watchDog(String name);
}
package xxx;
import jsinterop.annotations.JsMethod;
import jsinterop.annotations.JsType;
@JsType(isNative = true)
public class WatchDog {
private WatchDog() {}
@JsMethod
public native void register(Callback callback);
@JsMethod
public native void broadcast(String msg);
}
package xxx;
import jsinterop.annotations.JsFunction;
@JsFunction
public interface Callback {
void call(Object event);
}
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
public interface Callback {
void call(ArgT event);
}
@JsType
inerface ArgT {
@JsProperty A getA();
@JsProperty B getB();
// e.t.c
}
}
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
package xxx;
import jsinterop.annotations.JsFunction;
@JsFunction
public interface Callback {
void call(Object event);
}
regarding 1) It would be nice to initialize Objects from json. What would happen if the json text specifies members not in class though?
You could always do this, if you just need to pass something to JavaScript and do not need to read it...
@JsType(isNative=true, name="JSON", namespace=@JsPackage.GLOBAL)
public class JSON {
Object parse(String json);
}
....
Object config=JSON.parse("{foo:1, bar: ["a","b","c"], baz: {a: true, b: false}}");
Vassilis Virvilis
--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsub...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.