[Pas2js] Progressive Web Apps

Ulrich, Christian christian.ulrich at tcsag.de
Mon Nov 12 07:27:43 CET 2018


PWA is my application.
The topic is and was to inject asm Blocks in an Unit outside the rtl scope. 
You wanted an example for what this is good for and I answered with my PWA example.

-----Ursprüngliche Nachricht-----
Von: Pas2js [mailto:pas2js-bounces at lists.freepascal.org] Im Auftrag von Mattias Gaertner via Pas2js
Gesendet: Samstag, 10. November 2018 09:22
An: pas2js at lists.freepascal.org
Cc: Mattias Gaertner
Betreff: [Pas2js] Progressive Web Apps

On Fri, 9 Nov 2018 13:25:02 +0000
"Ulrich, Christian" <christian.ulrich at tcsag.de> wrote:

The other thread was about a "variable in the .LPR file so that
it can be used by all the units in the project".
PWA is a different topic.

> I must execute code as fast as possible after loading the index
> (Progressive Web Apps must install an handler to handle
> caching/updates of the page to be able to handle offline requests
> right) And I want to do that before loading the rtl js and my
> librarys and so on and naturally long before rtl.run is called

Note that you can use -JiYourStartCode.js -Jirtl.js to insert
YourStartCode.js before the rtl.js.

If the callback references some Pascal code then you can do the
following:

program project1;

{$mode objfpc}

uses
  browserapp, JS, Classes, SysUtils, Web;

type
  TMyApplication = class(TBrowserApplication)
    procedure doRun; override;
  end;

procedure TMyApplication.doRun;

begin
  // Your code here
  Terminate;
end;

function Run(Event: TEventListenerEvent): boolean;
var
  Application : TMyApplication;
begin
  Application:=TMyApplication.Create(nil);
  Application.Initialize;
  Application.Run;
  Application.Free;
  Result:=true;
end;

begin
  // add callbacks for PWA
  // ...
  // delay starting the application
  window.addEventListener('load', @Run);
end.

 
> But it would be nice to be able to handle the caching Stuff in an
> Pascal class and just injecting the installation of the handlers in
> asm in the same unit

Can you give an example for such a handler?


Mattias
_______________________________________________
Pas2js maillist  -  Pas2js at lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js


More information about the Pas2js mailing list