[Pas2js] Just sharing the class helpers importance

silvioprog silvioprog at gmail.com
Sat Dec 22 23:06:44 CET 2018


On Sat, Dec 22, 2018 at 5:08 AM Michael Van Canneyt <michael at freepascal.org>
wrote:

> I agree totally, but I should point out that then we'll have 2 kinds of
> type
> helpers: normal ones (where you write the code)  or external ones (where
> the
> code is in a mixin javascript library).
>
> That would require an extra keyword to be added.
> So for your example,  this would be something like:
>
> TAutoTableHelper = type helper external for class TJSPDF
>    procedure autoTable(aCols,aRows : Integer);
> end;
>
> This way the compiler knows that the type helper does not contain any code.
>
> Another possibility (maybe faster to implement) would be an 'external'
> interface, but that would require a typecast to be used, so a type helper
> will
> be easier to use. So currently I think we'll probably do that then.
>
> We'll keep it in mind for when we start with the type helpers.
>

It sounds very good. I'll use the way extending a class. :-)

I solved it temporally using:

TjsPDF = class external name 'jsPDF'
public
  ... jsPDF's methods / properties ...

  { TODO: move this method to the TjsPDFAutoTable class as soon
    as the class helpers feature is available in pas2js. :-) }
  function autoTable(headers: TJSArray; data: TJSArray;
    tableOptions: JSValue = nil): TjsPDF;
end;

This method above allows me to generate complex auto paginated reports with
a clean and great appearance. :-) I'll contribute those plugins to the
pas2js RTL as soon as possible.


> Thanks for pointing it out !
>
> Michael.


You're welcome dude, and thank you too! :-)

-- 
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20181222/ebb355ed/attachment.html>


More information about the Pas2js mailing list