futuristic icon indicating copy to clipboard operation
futuristic copied to clipboard

Wait for multiple promises to "be done"

Open vespakoen opened this issue 11 years ago • 5 comments

Hi there!

In other promise libraries I was able to do something like:

$.when($.ajax( "api/pages" ), $.ajax( "api/pagecategories" )).done(function(pages, categories));

Is this possible with futuristic? If not, are there any plans to add this in?

vespakoen avatar Jan 10 '14 11:01 vespakoen

@vespakoen this is something that I wanted since the beginning, but I was not comfortable with the results after implementing it. I'll implement it on the next release. at the moment I'm rewriting this gem. sorting out things that didn't work out as I wanted.

seanlilmateus avatar Jan 12 '14 13:01 seanlilmateus

@vespakoen I have a new branch Version 1.0, on this branch the feature you're looking is implemented. but I changed a lot on the design. At the moment I'm trying to document everything.

seanlilmateus avatar Feb 17 '14 20:02 seanlilmateus

Hi, just chiming in here - have you ever thought if it might be possible to use Futuristic promises with AFMotion? It'd be awesome if I could encapsulate an AFMotion request behind a promise (or future) so that the block called when the AFMotion request finishes ends up 'completing' the promise. Is that something you have considered? It'd make a whole lot of back-end interaction code (for example, with a RESTful API) so much easier to write, and profoundly more readable as code.

matthewsinclair avatar Feb 18 '14 01:02 matthewsinclair

@matthewsinclair this is one of features the new branch introduces. You will be able to use Promises to accomplish this kind of thing and even react to error. Tonight will be working on the specs and documentation.

e.g: https://github.com/seanlilmateus/futuristic/blob/version_1_0/lib/futuristic/future.rb#L6-L15

seanlilmateus avatar Feb 18 '14 08:02 seanlilmateus

That sounds brilliant. I think that pattern will radically simplify the code for a lot of network / async operations. Thanks!

On 18 Feb 2014, at 7:05 pm, Mateus [email protected] wrote:

@matthewsinclair this is one of features the new branch introduces. You will be able to use Promises to accomplish this kind of thing and even react to error. Tonight will be working on the specs and documentation.

— Reply to this email directly or view it on GitHub.

matthewsinclair avatar Feb 18 '14 08:02 matthewsinclair