On Wed, Aug 20, 2014 at 6:17 AM, Cristian Rinaldi <csrina...@gmail.com>
wrote:

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


There will be some static helpers provided from the SDK. I originally
started the JSNI 2.0 document but it is basically waiting for me to start
on Elemental 2.0 and accumulate more experience to turn it into something
more concrete.



>      2) How do when an instance is mapped to an existing Object, eg
> Promise, has a constructor with parameters?
>
>

Actually I have new ideas on this derived from how some other APTs work.

I need to update the JsInterop doc but these are the options that I'm
thinking right now:

*Option 1 (works better for extending):*

@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);
}

​

*Option 2 (works better for general use):*

@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);
}

​

*Of course one can do both:*

@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: JS
> <https://github.com/workingflows/gwt-jscore/blob/master/src/main/java/com/workingflows/js/jscore/client/factory/JS.java>
>
>     But 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:
>
>     https://github.com/workingflows/gwt-jscore/
> <https://github.com/workingflows/gwt-jscore/>
>
>
Great work. This kind of stuff is also very valuable as a feedback.


> 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-contributors+unsubscr...@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
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/3268ccc7-9953-49c9-9079-574096f0d5d3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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-contributors+unsubscr...@googlegroups.com.
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to