Re: wait for callback and use results of return value

Karsten Kusche <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
Hi Sabine,

i don’t know what exactly you mean with 1 and 2 but i assume getS3Data() returns immediately and its result is sent to the server. If getS3Data() performs an asynchronous call, the method is pretty quick and doesn’t block.

What you need to do is something like this (from the jQuery website):


var jqxhr = $.ajax( "example.php" )
  .done(function() {
    alert( "success" );
  })
  .fail(function() {
    alert( "error" );
  })
  .always(function() {
    alert( "complete" );
  });

You create the Ajax request to S3 and in the done-function you can to handle the result and pass it to a callback. I can’t tell you how to do that out of my head though, it shouldn’t be too hard though.

Kind Regards
Karsten


Am 21. November 2018 um 14:57:04, Sabine Manaa ([email protected]<mailto:[email protected]>) schrieb:

Hi,

I have spent several hours in the following problem: I want to use a list of
names in Pharo which I get from amazon S3. But it is not a aws problem but a
problem of understanding how to use callbacks/asynchronus code and return
values. This is a simplified version for describing the problem. Pressing
the button "testing" evaluates the Javascript code below. The result, I want
to use in Pharo is the result which is at *1*. But the method immediately
returns the result at *2*, because it dose not wait for the function to be
completed. This is more a javascript question but perhaps someone had a
similar problem.
Perhaps someone has an idea. I already tried with promises but did not
succeed.

Sabine


renderTestOn: html
html
html:
''.

html div
onClick:
(html jQuery ajax callback: [ :var | var inspect ] value: (JSStream on:
'getS3Data()'));
with: 'testing'



--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.