If you’re looking for a cross-platform application that demonstrates how to do an asynchronous REST API call, look no further than the Async REST Demo. This powerful little app is built in Delphi using a single code base and single UI, making it truly cross-platform. And because it’s asynchronous, you can be sure that your results are always up-to-date. Supports Android, iOS, macOS, Windows, and Linux.
Download the full cross-platform Hello World source code on Github.
This demo is part of over 100 cross-platform demos with everything from camera demos to emoji demos and painting demos.
Inhaltsverzeichnis
What does asynchronous mean in software development?
In software development, asynchronous refers to a type of communication between two or more components where each component can proceed independently of the others. This contrasts with synchronous communication, where each component must wait for a response from the others before it can continue. Asynchronous communication often occurs in event-driven systems, where each component can respond to events as they occur without waiting for input from the other components. This type of communication can improve performance and responsiveness by reducing or eliminating bottlenecks. In addition, asynchronous communication can provide a more robust and scalable system by allowing components to handle different workloads independently.
Screenshot
What is the source code of the demo?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Klassen, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, REST.Types, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, System.Rtti, FMX.Gitter.Style, Data.Bind.EngExt, Fmx.Bind.DBEngExt, Fmx.Bind.Gitter, System.Bindings.Outputs, Fmx.Bind.Editors, FMX.StdCtrls, Data.Bind.Komponenten, Data.Bind.Gitter, Data.Bind.DBScope, FMX.ScrollBox, FMX.Gitter, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, REST.Response.Adapter, REST.Client, Data.Bind.ObjectScope, FMX.Effects, FMX.Controls.Presentation, FMX.Memo, FireDAC.Stan.StorageJSON, FMX.Memo.Types; type TForm1 = Klasse(TForm) MaterialOxfordBlueSB: TStyleBook; ToolBar1: TToolBar; ShadowEffect4: TShadowEffect; Label1: TLabel; RESTClient1: TRESTClient; RESTRequest1: TRESTRequest; RESTResponse1: TRESTResponse; RESTResponseDataSetAdapter1: TRESTResponseDataSetAdapter; FDMemTable1: TFDMemTable; Button1: TButton; Memo1: TMemo; FDStanStorageJSONLink1: TFDStanStorageJSONLink; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.fmx} <strong>procedure TForm1.Button1Click(Sender: TObject); Start Memo1.Lines.klar; RESTRequest1.ExecuteAsync( procedure Start Label1.Text := 'Complete!'; Memo1.Lines.Append('Userid: ' + FDMemTable1.FieldByName('Userid').AsString); Memo1.Lines.Append('id: ' + FDMemTable1.FieldByName('id').AsString); Memo1.Lines.Append('title: ' + FDMemTable1.FieldByName('title').AsWideString); Memo1.Lines.Append('body: ' + FDMemTable1.FieldByName('body').AsWideString); end, True, True, procedure (Sender: TObject) Start Label1.Text := 'Error!'; end); end;</strong> end. |
Ready to learn how to program cross-platform apps like this?
Sign up for the Coding Boot Camp 2022 to learn to program. Topics include: Games, JavaScript, Web, Python, SQL, Databases, iOS, MacOS, Android, Mobile, Linux, Windows, Desktop, Server, and Arduino.