Closed rzhghost closed 3 years ago
Hello @rzhghost. Sorry for closing the issue. I've miss clicked.
No. The TPromise object extends TInterfacedObject. So, it not need to be released. See the example in sample/uMainForm.pas, lines 43-90. Note that the promise was created, but not captured in a reference. So, it cannot be/do not need to be released. Either if you capture a reference, do not release it. Releasing an TInterfacedObject extended class will give you EInvalidOperationException.
About not beeing possible to compile on MacOS, can you attach the error message, please?
Kind regards.
compile error message: [dccosx64 Fatal Error] Unit1.pas(52): F2084 Internal Error: LC6648
my test code:
uses promise, promise.concret, System.Threading;
{$R *.fmx}
procedure TForm1.Button1Click(Sender: TObject);
begin
TPromise<String, Exception>.NewAsync(
procedure (Resolve: TPromiseResolveProcedure<String>; Reject: TPromiseRejectProcedure<Exception>)
begin
sleep(4000);
Resolve('OK');
end
)
.&Then(
procedure (const Value: String)
begin
TThread.Queue(
nil,
procedure
begin
Form1.Button1.Text := Value;
end);
end
);
end;
It seems that other platforms do not support except window platform. Maybe Delphi does not support some syntax(Delphi10.4.2)
@rzhghost. Thanks for your feedback. You're right: on FMX application it results on compilation error "Internal Error" when deploying to Android too.
I've made [break] changes to fix this. So, the older TPromise (windows working version) is still available under tag 1.1.0. The new version (2.0.0) is available on master branch. Please, check if this fix your problem.
I have not deployed a README.md to 2.0.0 version, so, please, follow to sample to see how to use the new version. It contains an API fetch example and a fake long process. I'ill do so in a near future.
Please, let me know if this fix your problem.
Kind regards.
Now there are no problems. I test normal on these platforms (MAC OS, Android, Linux, Win32, win64, IOS). Thank you for your efforts!!!
on macos Cannot compile