gulpjs / async-done

Allows libraries to handle various caller provided asynchronous functions uniformly. Maps promises, observables, child processes and streams, and callbacks to callback style.
MIT License
70 stars 21 forks source link

Add RxJS support #3

Closed phated closed 10 years ago

phated commented 10 years ago

See: https://gist.github.com/mattpodwysocki/ff72b3f66d871501e576

phated commented 10 years ago

@mattpodwysocki just added the code, not sure how to right the tests. See https://github.com/phated/async-done/commit/f4ee74b689351498a89f8f77ee8d21f68b806ad1 for implementation.

bnjmnt4n commented 10 years ago

I will send a PR for this tomorrow :)

mattpodwysocki commented 10 years ago

@phated @d10 Change the RxJS code to the following:

    if(result && typeof result.subscribe === 'function') {
      // assume RxJS observable
      result.subscribe(onSuccess, onError);
      return;
    }

This will assume then we only have one and only one value in the pipeline. Meaning would it be bad if done is called twice? If that's the case that it's bad, we can fix that by doing the following:

    if(result && typeof result.subscribe === 'function') {
      // assume RxJS observable
      result.take(1).subscribe(onSuccess, onError);
      return;
    }
phated commented 10 years ago

Landed in https://github.com/phated/async-done/commit/7ccf6dfaf7014761ba0b9e8d5eae434233a29e68 - Thanks @mattpodwysocki and @d10