You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2021/10/23 22:35:33 UTC

Externs that returns a value instead of void method

Hi,

How to use a method in externs (
https://apache.github.io/royale-docs/features/externs) that returns a value.

I tried: public static function getDocumentAsPDF():Object { return null; }

But of course that returns null (even the JS version returns a value)

Re: Externs that returns a value instead of void method

Posted by Josh Tynjala <jo...@bowlerhat.dev>.
When you create externs, the code is used only for type checking by the
compiler, and it doesn't generate JavaScript code. In other words, it won't
affect runtime behavior at all. You could return anything, and it won't
matter. Null is fine, and I think that's what most people use.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Sat, Oct 23, 2021 at 3:35 PM Hugo Ferreira <hf...@gmail.com>
wrote:

> Hi,
>
> How to use a method in externs (
> https://apache.github.io/royale-docs/features/externs) that returns a
> value.
>
> I tried: public static function getDocumentAsPDF():Object { return null; }
>
> But of course that returns null (even the JS version returns a value)
>

Re: Externs that returns a value instead of void method

Posted by Hugo Ferreira <hf...@gmail.com>.
Thank you very much to point that.

Kessler CTR Mark J <ma...@usmc.mil.invalid> escreveu no dia
segunda, 25/10/2021 à(s) 12:11:

> Hugo,
>     If you are using the @externs in the class comments, use a native on
> function and it will ignore its requirement to actually have a body.  It
> can remain just a declaration.  The other thing that caused us problems in
> the beginning is we needed a change to the release compilation properties
> to optimize only the whitespace, because it was mangling our external
> namespaces if not.
>
> public native static function getDocumentAsPDF():Object;
>
> r/s
> -Mark K
>
> -----Original Message-----
> From: Maria Jose Esteve <mj...@iest.com>
> Sent: Sunday, October 24, 2021 07:32
> To: dev@royale.apache.org
> Subject: [Non-DoD Source] RE: Externs that returns a value instead of void
> method
>
> If you want I have several projects with externs that you could look at to
> see different wrappers.
> Depending on how the JS library is set up you will have some problems or
> others 😝 but in general they work very well.
>
> - [1] royale-community-examples project: Here you have a wrapper for
> VirtualSelect, JSCalendar, JsFullCalendar and we are finishing one for
> InspireTree.
> - [2] royale-echarts examples project: wrapper for the Apache Echarts
> incubator graphics library.
>
> [1] https://github.com/mjesteve/royale-examples-community/tree/develop
> [2] https://github.com/mjesteve/Royale-ECharts/tree/develop
>
> I hope they will help you.
> Hiedra.
>
> -----Mensaje original-----
> De: Yishay Weiss <yi...@apache.org>
> Enviado el: domingo, 24 de octubre de 2021 9:15
> Para: dev@royale.apache.org
> Asunto: Re: Externs that returns a value instead of void method
>
> Are you compiling the PDF typdefs as a separate lib? If so, you need to
> make sure the application compiler treats it as a js-external-library. If
> you do that, as Josh pointed out, no js output from the lib will be
> included in your application so it shouldn't matter what actual values you
> return, as long as it compiles.
>
> On 2021/10/23 22:35:33, Hugo Ferreira <hf...@gmail.com> wrote:
> > Hi,
> >
> > How to use a method in externs (
> > https://apache.github.io/royale-docs/features/externs) that returns a
> value.
> >
> > I tried: public static function getDocumentAsPDF():Object { return null;
> }
> >
> > But of course that returns null (even the JS version returns a value)
> >
>

RE: Externs that returns a value instead of void method

Posted by Kessler CTR Mark J <ma...@usmc.mil.INVALID>.
Hugo,
    If you are using the @externs in the class comments, use a native on function and it will ignore its requirement to actually have a body.  It can remain just a declaration.  The other thing that caused us problems in the beginning is we needed a change to the release compilation properties to optimize only the whitespace, because it was mangling our external namespaces if not.

public native static function getDocumentAsPDF():Object;

r/s
-Mark K

-----Original Message-----
From: Maria Jose Esteve <mj...@iest.com> 
Sent: Sunday, October 24, 2021 07:32
To: dev@royale.apache.org
Subject: [Non-DoD Source] RE: Externs that returns a value instead of void method

If you want I have several projects with externs that you could look at to see different wrappers.
Depending on how the JS library is set up you will have some problems or others 😝 but in general they work very well.

- [1] royale-community-examples project: Here you have a wrapper for VirtualSelect, JSCalendar, JsFullCalendar and we are finishing one for InspireTree.
- [2] royale-echarts examples project: wrapper for the Apache Echarts incubator graphics library.

[1] https://github.com/mjesteve/royale-examples-community/tree/develop
[2] https://github.com/mjesteve/Royale-ECharts/tree/develop

I hope they will help you.
Hiedra.

-----Mensaje original-----
De: Yishay Weiss <yi...@apache.org> 
Enviado el: domingo, 24 de octubre de 2021 9:15
Para: dev@royale.apache.org
Asunto: Re: Externs that returns a value instead of void method

Are you compiling the PDF typdefs as a separate lib? If so, you need to make sure the application compiler treats it as a js-external-library. If you do that, as Josh pointed out, no js output from the lib will be included in your application so it shouldn't matter what actual values you return, as long as it compiles.

On 2021/10/23 22:35:33, Hugo Ferreira <hf...@gmail.com> wrote: 
> Hi,
> 
> How to use a method in externs (
> https://apache.github.io/royale-docs/features/externs) that returns a value.
> 
> I tried: public static function getDocumentAsPDF():Object { return null; }
> 
> But of course that returns null (even the JS version returns a value)
> 

Re: Externs that returns a value instead of void method

Posted by Hugo Ferreira <hf...@gmail.com>.
The problem is that I was running a promise inside my JS wrapper.
I return the promise now and use it in AS3 as promise.then() and problem
solved.

Thank you all.

Maria Jose Esteve <mj...@iest.com> escreveu no dia domingo, 24/10/2021
à(s) 12:32:

> If you want I have several projects with externs that you could look at to
> see different wrappers.
> Depending on how the JS library is set up you will have some problems or
> others 😝 but in general they work very well.
>
> - [1] royale-community-examples project: Here you have a wrapper for
> VirtualSelect, JSCalendar, JsFullCalendar and we are finishing one for
> InspireTree.
> - [2] royale-echarts examples project: wrapper for the Apache Echarts
> incubator graphics library.
>
> [1] https://github.com/mjesteve/royale-examples-community/tree/develop
> [2] https://github.com/mjesteve/Royale-ECharts/tree/develop
>
> I hope they will help you.
> Hiedra.
>
> -----Mensaje original-----
> De: Yishay Weiss <yi...@apache.org>
> Enviado el: domingo, 24 de octubre de 2021 9:15
> Para: dev@royale.apache.org
> Asunto: Re: Externs that returns a value instead of void method
>
> Are you compiling the PDF typdefs as a separate lib? If so, you need to
> make sure the application compiler treats it as a js-external-library. If
> you do that, as Josh pointed out, no js output from the lib will be
> included in your application so it shouldn't matter what actual values you
> return, as long as it compiles.
>
> On 2021/10/23 22:35:33, Hugo Ferreira <hf...@gmail.com> wrote:
> > Hi,
> >
> > How to use a method in externs (
> > https://apache.github.io/royale-docs/features/externs) that returns a
> value.
> >
> > I tried: public static function getDocumentAsPDF():Object { return null;
> }
> >
> > But of course that returns null (even the JS version returns a value)
> >
>

RE: Externs that returns a value instead of void method

Posted by Maria Jose Esteve <mj...@iest.com>.
If you want I have several projects with externs that you could look at to see different wrappers.
Depending on how the JS library is set up you will have some problems or others 😝 but in general they work very well.

- [1] royale-community-examples project: Here you have a wrapper for VirtualSelect, JSCalendar, JsFullCalendar and we are finishing one for InspireTree.
- [2] royale-echarts examples project: wrapper for the Apache Echarts incubator graphics library.

[1] https://github.com/mjesteve/royale-examples-community/tree/develop
[2] https://github.com/mjesteve/Royale-ECharts/tree/develop

I hope they will help you.
Hiedra.

-----Mensaje original-----
De: Yishay Weiss <yi...@apache.org> 
Enviado el: domingo, 24 de octubre de 2021 9:15
Para: dev@royale.apache.org
Asunto: Re: Externs that returns a value instead of void method

Are you compiling the PDF typdefs as a separate lib? If so, you need to make sure the application compiler treats it as a js-external-library. If you do that, as Josh pointed out, no js output from the lib will be included in your application so it shouldn't matter what actual values you return, as long as it compiles.

On 2021/10/23 22:35:33, Hugo Ferreira <hf...@gmail.com> wrote: 
> Hi,
> 
> How to use a method in externs (
> https://apache.github.io/royale-docs/features/externs) that returns a value.
> 
> I tried: public static function getDocumentAsPDF():Object { return null; }
> 
> But of course that returns null (even the JS version returns a value)
> 

Re: Externs that returns a value instead of void method

Posted by Yishay Weiss <yi...@apache.org>.
Are you compiling the PDF typdefs as a separate lib? If so, you need to make sure the application compiler treats it as a js-external-library. If you do that, as Josh pointed out, no js output from the lib will be included in your application so it shouldn't matter what actual values you return, as long as it compiles.

On 2021/10/23 22:35:33, Hugo Ferreira <hf...@gmail.com> wrote: 
> Hi,
> 
> How to use a method in externs (
> https://apache.github.io/royale-docs/features/externs) that returns a value.
> 
> I tried: public static function getDocumentAsPDF():Object { return null; }
> 
> But of course that returns null (even the JS version returns a value)
>