@JsType(isNative = true, prototype = "Promise")
public interface Promise {
void then(Function f);
void cath(Function f);
}
Community:I'm playing with JsInterop , and I have two questions:1) Are you planning to try the static methods of JS objects, such as Object, Promise, etc.?
2) How do when an instance is mapped to an existing Object, eg Promise, has a constructor with parameters?
@JsType(prototype = "Promise")
public interface Promise {
/* Protoype_Promise is an autogenerated package visible class */
public static class Prototype extends Protoype_Promise {
public Prototype(Function... functions) {
super(functions);
}
}
void then(Function f);
void cath(Function f);
}
@JsType(prototype = "Promise")
public interface Promise {
/* Protoype_Promise is an autogenerated package visible class */
public static Promise create(Function... functions) {
return new Protoype_Promise(functions);
}
void then(Function f);
void cath(Function f);
}
@JsType(prototype = "Promise")
public interface Promise {
public static class Prototype extends Protoype_Promise {
public Prototype(Function... functions) {
super(functions);
}
}
public static Promise create(Function... functions) {
return new Prototype(functions);
}
void then(Function f);
void cath(Function f);
}
Currently to resolve this 1) I created the following class Factory: JSBut the interfaces define a contract at the level instance of a class or object, this way of doing things, I do not know if it is semantically correct.To solve 2) there are not many options:Create a Factory that returns an instance of the object, because it has no meaning, only to make the new, implement the interface, because the compiler already does.There is some progress in this?I saw in one of the post a proposal to do something like this:Promise Promise.Prototype p = new (new Function ....., new Function ....);
Where Promise, is the interface defined with prototype = "Promise".@JsType(isNative = true, prototype = "Promise")
public interface Promise {
void then(Function f);
void cath(Function f);
}
Here 'access to jsCore project:
I hope the answers ...greetings
--
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/3268ccc7-9953-49c9-9079-574096f0d5d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA0ZpjT%2Bf%2ByqbwCHsSSPWaawLtJwf%2BPTTvbd68zE2Oxh%2Bw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAPVRV7eq1ZNZKCj22mYk9ttKkE%2BammBWuV1KPDN5e%2BM_by5TsQ%40mail.gmail.com.
Are we ballsy enough to say GWT 3.0 = Java8 source level enforced for client side code?
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-contributors+unsubscribe@googlegroups.com.
Thanks +Goktug Gokdogan for response.
APT is very good option and java 8 support for GWT 3.0 would be a amazing thing.You have a planning for Elemental 2.0 or initial documentation to share, to how you plan address the desing?
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/44fbf2d1-d791-4e7b-8078-5e804c3da99e%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAN%3DyUA24BTLYVB3KyiuV4dLu-ZUT-y%2By-_C128p1Zi_3e%2BnvMA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAPVRV7eudUi9pHJR2nhMOjoWJ%3Dd57G42aOr5rFU5UUdGTpnX%2BA%40mail.gmail.com.
@JsType(isNative = true, prototype = "Promise")
public interface Promise {
Promise then(PromiseThenFn f, PromiseThenFn error);
@JsAlias(value="catch")
Promise catchError(PromiseThenFn error);
}var p = new Promise (function (resolved, rejected) {...}); @JsType
public interface PromiseFn {
void f(Resolve resolve, Rejected rejected);
}
// In JS Class Factory
public static native PromiseFn Function(PromiseFn fn) /*-{
return function(resolve, rejected){
fn.f(resolve, rejected);
}
}-*/;final Promise p3 = Browser.newPromise(JS.Function(new PromiseFn() {
@Override
public void f(Resolve resolve, Rejected rejected) {
resolve.resolve("Resolve Promise P3");
}
}));
Promise p1 = Browser.newPromise(JS.Function(new PromiseFn() {
@Override
public void f(Resolve resolve, Rejected rejected) {
resolve.resolve("Resolve Promise P1");
}
}));
p1.then( JS.Function( new PromiseThenFn() { @Override public Promise f(final Object changed) { Browser.getWindow().getConsole().log("Promise Complete: " + changed); return Browser.newPromise(JS.Function(new PromiseFn() { @Override public void f(Resolve resolve, Rejected rejected) { resolve.resolve(changed + " > Other Promise"); } })); } }), JS.Function( new PromiseThenFn() { @Override public Promise f(final Object changed) { Browser.getWindow().getConsole().log("Promise with Error: " + changed); return Browser.newPromise(JS.Function(new PromiseFn() { @Override public void f(Resolve resolve, Rejected rejected) { rejected.rejected(changed + " > Other With Error Promise"); } })); } }) ).then( JS.Function( new PromiseThenFn() { @Override public Promise f(final Object changed) { Browser.getWindow().getConsole().log("Promise Complete: " + changed); return null; } }),
JS.Function( new PromiseThenFn() { @Override public Promise f(Object changed) { Browser.getWindow().getConsole().log("Promise with Error: " + changed); return null; } }) );I followed with JsInterop and implement a basic version of Promise (not full implemented).The code is here:1) https://github.com/workingflows/gwt-jscore/tree/master/src/main/java/com/workingflows/js/jscore/client/api/promise (Promise API)2) https://github.com/workingflows/gwt-jscore/tree/master/src/main/java/com/workingflows/js/jscore/client/factory (Factory API)I found some things, for example:Promise has the "catch" method, and this is a reserved word in Java.Then, on the interface that represents Promise, can not be put this method. Perhaps, there could be a JsAlias for functions:@JsType(isNative = true, prototype = "Promise")
public interface Promise {
Promise then(PromiseThenFn f, PromiseThenFn error);
@JsAlias(value="catch")
Promise catchError(PromiseThenFn error);
}
Another annoying thing is the management function as a parameter, for example:In JS:var p = new Promise (function (resolved, rejected) {...});In Java I emulated it this way, and if not the best:@JsType
public interface PromiseFn {
void f(Resolve resolve, Rejected rejected);
}
// In JS Class Factory
public static native PromiseFn Function(PromiseFn fn) /*-{
return function(resolve, rejected){
fn.f(resolve, rejected);
}
}-*/;
@Functional
public interface PromiseFn {
void f(Resolve resolve, Rejected rejected);
}
final Promise p3 = Browser.newPromise(new PromiseFn() {
@Override
public void f(Resolve resolve, Rejected rejected) {
resolve.resolve("Resolve Promise P3");
}
});
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit-contributors/b4c4bfb4-9470-49a0-9ab2-67e855ed1a0c%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.